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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Query in VBA?

Status
Not open for further replies.

Petemush

Technical User
Jun 21, 2002
255
GB
Hi,

I have a form with a messagebox appearing confiming a users actions. It asks the user whether they would like to

add (insert control value here)
with this data (insert second control value here)

I have no problem referencing the controls but the first value is code which relates to a training course and is a little vague.

Is it possible to use the code provided and search through the training courses table to extract the name of the course? Using VBA? SELECT...INTO isn't much use here as I just want to match something and I don't really want to create a query if it can be done in code.

So any ideas?

Cheers,

Pete
 
Before displaying the message, use the control value and dlookup to get the training course name.
Code:
dim sDescrip as string

sDescrip = DLookup("Fieldname", "TableName","traincode=" & me!ControlValue)

Fieldname= The fieldname of the course description, this is the value returned
Tablename=training table
traincode etc = the criteria for selection (a WHERE clause without the WHERE)

Then sDescrip could be inserted into your message. Hope this makes sense.
 
Duh!

Cheers, had a bit of a break from using Access so a lot has dropped out of my head!

Thanks again,

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top