Using select instead of dlookup (1 Viewer)

lcline

Registered User.
Local time
Today, 23:41
Joined
Oct 23, 2001
Messages
53
Thanks in advance,

In the past i have used dlookup to find specfic fields from a table.

I was thinking that a select statement would be more efficient as I need to return 4 fields for one specific record.

I tried the following but keep getting error 3061 Too Few Parameters Expected 1.

My question is which is more efficent 4 dlookups or the select method.

If the answer is the select method, why am I getting the error.

SelectSql = ("SELECT dbo_R_D_Event_Date.RID," _
& " dbo_R_D_Event_Date.Install_Shift, dbo_R_D_Event_Date.Station," _
& " dbo_R_D_Event_Date.Install_Emp" _
& " FROM dbo_R_D_Event_Date" _
& " WHERE dbo_R_D_Event_Date.PartID ='" & Me.txtInstall & "'")

Set rs = CurrentDb.OpenRecordset(SelectSql)

thanks again
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 18:41
Joined
Feb 19, 2002
Messages
43,546
If PartID is numeric, as its name implies, remove the quotes from around txtInstall.

BTW, You are correct about efficiency but the really best way is to join the lookup tabl to the main table in the form's RecordSource query. That way you won't need any code at all. When you do this, be sure to delete the original queryname from the RecordSource property and then add it back. This will force the form to requery the RecordSource. When you use this technique, it is important to set the locked property of the lookup fields to Yes to prevent accidental update.
 

Users who are viewing this thread

Top Bottom