Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA help

Status
Not open for further replies.

Daya100

Programmer
Jan 11, 2002
21
US
I'm somewhat of a beginner with VBA and desperately need help. I have a form in my Access DB and have a button to create a new record in the table. I'm having trouble putting together the unique ID. Once the user clicks on the new record button then I have an input box to prompt them for a 6 digit number called GL. That number relates to a 2 letter code - they are both in another table (not the one the form is based on). The ID I assign in going to be 01-XX-0000 where the XX is the 2 letter code in the other table. How do I pull that 2 letter code to put into my unique ID field on the main form???
Thanks for any help!
 
One solution might be to use the DLOOKUP and the MID functions (see online help for the syntax).
Alternatively you could use global variables in order to speed up your code: read the letters once and remember them.

Happy programming!
Fran
 
Thanks - now I'm having trouble with the Dlookup. This is what I have:
strResult = DLookup("MktCode", "MarketIDs", "GL" = strInput)

I'm trying to make the criteria for the "GL" field in the table to be equal to the the result of what the user types in the input box. The result of what they enter in the input box equals the string expression strInput. So - how do I make the GL equal that?

Thanks!!!
 
Try it like this...

strResult = DLookup("MktCode", "MarketIDs", "GL='" & strInput & "'")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top