Value dependant upon combo box choice.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Yesterday I posted a question about the database I'm working on. I got the
first half done (which was for Access to create a "ticket number" based upon
the date and time entered on the form), but now I'm running into a roadblock.

I have a combo box with 2 choices--Trouble or Informational. If
Informational is selected, then I need access to use my created ticket number
and place it into that field. If trouble is selected I do not want anything
automatically done to the ticket number field.

Here is the VBA code that I have pieced together from reading the help file
and this message board:

If Me.TicketType = Informational Then Me.Event_Log_Ticket_Number = Me.Test1

This code is placed in the AfterUpdate event box for the combo box.

TicketType is the combo box with the 2 options.

Event_Log_Ticket_Number is where the ticket number is entered in (and in the
case of Informational being selected automatically entered in).

Test1 is the field that currently stores that ticket number that is created
by the calculation. My hope is that I can do away with this field and put
the calculation of the date into the function that is created to do the check.


Thanks in advance,

Sean Skallerud
 
You say what you have done, but you don't say what it does now, or where
it doesn't with the error.

My guess, though, is that you must use quotes around International. Er,
Informational. Like this:
If Me.TicketType = "Informational" Then Me.Event_Log_Ticket_Number = Me.Test1

Also note that the dot (.) is in fact reserved for methods and members.
TicketType, Event_Log_Ticket_Number and Test1 are neither: they are
controls, and are (strictly) referenced to using the bang (!)
In this case I wouldn't bother at all and leave the scope (Me.) out.
Test1 is the field that currently stores that ticket number that is created
by the calculation. My hope is that I can do away with this field and put
the calculation of the date into the function that is created to do the check.

Yes, that is correct. You can put the expression in the place of Test1
in the code.

Go on!
 
Back
Top