Hello all!
I am not an expert in programming, but I manage simple VBA coding in Access.
I have used the last few days searching online for a solution to my problem, but still havent found one. I think the solution is quite simple, i just cant figure out what it might be.
I am building a database for my employer. Its goal is to keep track of inventory. The different items in inventory differs greatly, and one have to add details to each inventory based on its type.
Right now I have a main form to register each item, and when the general registration if finished you choose what kind of item it is from a combobox. I have 11 different choices in the combobox.
What i want is to open a new form based on the selection the user makes in the combobox.
My code is this:
This code works fine when i use 1 IF-statement (end the code after strmform= "Openform1"), but it fails when i add more statements (Ii get error message "Run-time error '2494.: You have to assign a form-argument for the action").
What is wrong with mye code? Can someone please help me.
I am not an expert in programming, but I manage simple VBA coding in Access.
I have used the last few days searching online for a solution to my problem, but still havent found one. I think the solution is quite simple, i just cant figure out what it might be.
I am building a database for my employer. Its goal is to keep track of inventory. The different items in inventory differs greatly, and one have to add details to each inventory based on its type.
Right now I have a main form to register each item, and when the general registration if finished you choose what kind of item it is from a combobox. I have 11 different choices in the combobox.
What i want is to open a new form based on the selection the user makes in the combobox.
My code is this:
Dim strform as String
If Me.CboName = "Choice1" Then
strform = "OpenForm1"
ElseIf Me.CboName = "Choice2" Then
strform = "Openform2"
Elseif Me.CboName = "Choice 3" Then
strform = "Openform3"
End if
Docmd.openform strform
This code works fine when i use 1 IF-statement (end the code after strmform= "Openform1"), but it fails when i add more statements (Ii get error message "Run-time error '2494.: You have to assign a form-argument for the action").
What is wrong with mye code? Can someone please help me.
Last edited by a moderator: