View Full Version : Problem with setting a value in an If statement


Inkognito
01-15-2009, 02:29 AM
Hi there!:cool:

I am trying to use an If sentence to determine whether a combinationbox is "Bestilling" or "Bestilling_ut" and then set a variable to one of two values.

If Kombinasjonsboks11 = "Bestilling" then forlag = Landsetting
If Kombinasjonsboks11 = "Bestilling_ut" then forlag = Sjosetting

But this isn't working, 'forlag' isn't set to anything at all.:(

I have tried different approaches, using a text field instead of a variable and spreading the if sentence on several lines with endif etc, but nothing seem to be working.:confused:
I really need this to finish my form.

Any help?

KenHigg
01-15-2009, 03:06 AM
Maybe your logic is thinking Landsetting and Sjosetting are variables (and maybe they are?)?

Maybe:

If Kombinasjonsboks11 = "Bestilling" then forlag = "Landsetting"
If Kombinasjonsboks11 = "Bestilling_ut" then forlag = "Sjosetting"

Inkognito
01-15-2009, 03:22 AM
Absolutely perfect! :D

Thx :)

Pat Hartman
01-16-2009, 12:08 PM
If you were not getting a compile error due to the undeclared variables, you should change all your procedures to have the property - Option Explicit - set. Put it at the top of each code module and in Tools/Options set the property to require variable declarations. This could save you hours of debugging.