0

**I want to display all the Car Model names which are there in 2nd DE.

car 1 DE : Name ,Email and CarBrand

Car 2 DE: Type,Model

The Carbrand from DE1 and Type from DE2 have same values

Code:

%%[
Var @fname,@cartype,@models,@ModelName

set @fname = "FirstName"
Set @cartype = "CarBrand"
Set @email = "Email"

Set @Models = LookupRows('Car2','Type',@cartype)

Set @Modelsrowcount = Rowcount(@Models)

If @Modelsrowcount > 0 Then

For @i = 1 to @Modelsrowcount do 

Set @row = row(@Models,@i)
Set @ModelName = Field(@row,'Model')
 
next @i

ENDIF


] %%

Hello %%=v(@fname),
For your Choice of CarBrand : %%=v(@cartype) we have different Models available for you : %%=v(@ModelName)=%%

Error: A FOR statement is not closed with the required NEXT statement. ClientID: 100014646 JobID: 0 EmailID: 0 Index: 713 Statement: For your Choice of CarBrand : %%=v(@cartype) we have different Models available for you : %%=v(@ModelName)=%%{{/block}}

please help!!

1
  • Still same error showing up !
    – Rohan
    Feb 12, 2022 at 1:30

2 Answers 2

2

The issue comes from the output. You forgot to close the inline variable call %%=v()=%%.

See below:

Hello %%=v(@fname),
For your Choice of CarBrand : %%=v(@cartype) we have different Models available for you : %%=v(@ModelName)=%%

Should be:

Hello %%=v(@fname)=%%,
For your Choice of CarBrand : %%=v(@cartype)=%% we have different Models available for you : %%=v(@ModelName)=%%

The %%=v(@fname) and %%=v(@cartype) did not have the closing =%% which made it think the For in the sentence was an AMPscript command.

1
  • i did make that change but i am sill getting this error: A FOR statement is not closed with the required NEXT statement.
    – Rohan
    Feb 12, 2022 at 0:28
1

I feel almost bad for posting this as an answer, but I feel a need to illustrate this. Take your code, paste it into ampscript.io and help yourself learn writing code, isolating and debugging step-by-step.

The fix is everything that Gortonington said, plus:

Your closed ] %% bracket has a spurious space. Correct syntax is: ]%%

Respectfully, if you used the proper tools and a step-by-step approach, you would see this before you wrote a single statement. Don't take this the wrong way, we're all here to help, but in your own interest: instead of waiting 12 hours for an answer and updating your own post with help! comments, you can get to this error in 2 seconds:

enter image description here

after this and Gortonington's change, your entire code comes out with "no errors detected"

1
  • Thanks for the ANswer and yes i will use that website and start debugging by myself
    – Rohan
    Feb 17, 2022 at 19:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .