Using Variables From Queries

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

Guest

I have a query that filters out a record, there are fields I want to capture
in variables from the query. I Dim xEmp as string and after the query runs,
I say xEmp = EmployeeId where EmployeeId is a field in the query but I get
nothing. Can someone help me?

Thanks In Advance
 
How many records return from the query?

If only one record is returned, you can use

xEmp = DLookUp("EmployeeId","QueryName")

If more then one record returns from the query, you need to add a filter to
the DlookUp using a value such a key field

xEmp = DLookUp("EmployeeId","QueryName","KeyField=" & KeyField)
 
Ofer, Thank you for your help! The query has 4 related tables, do I have to
specify which table because The information it stores and the information I'm
looking at on the query differ
 
No, you don't need to specify the table name, unless the field you are
looking for is located on more then one table in the query, and they are both
list there as the output of the query.
 
Ofer Hi again. After this project - I quit!! Could you please look at this &
tell me what I'm doing wrong. The query opens, the filter works, but the
message box says the same thing, that xDeveloperName = 127 and xvaultNo = 0

Thanks An Advance
Wm

DoCmd.OpenQuery "qryBill"
DoCmd.ApplyFilter , "[Vault No] = " & [Forms]![FrmReleaseOffsite]![xVaultNo]
xDeveloperName = DLookup("DeveloperName", "qryBill")
 
Combine all three rows into one

xDeveloperName = DLookup("DeveloperName", "qryBill","[Vault No] = " &
[Forms]![FrmReleaseOffsite]![xVaultNo])

--
Good Luck
BS"D


williamr said:
Ofer Hi again. After this project - I quit!! Could you please look at this &
tell me what I'm doing wrong. The query opens, the filter works, but the
message box says the same thing, that xDeveloperName = 127 and xvaultNo = 0

Thanks An Advance
Wm

DoCmd.OpenQuery "qryBill"
DoCmd.ApplyFilter , "[Vault No] = " & [Forms]![FrmReleaseOffsite]![xVaultNo]
xDeveloperName = DLookup("DeveloperName", "qryBill")

Ofer Cohen said:
No, you don't need to specify the table name, unless the field you are
looking for is located on more then one table in the query, and they are both
list there as the output of the query.
 
Ofer, Hi Again. That worked but now I have other problems. Thank you very
much!!

Wm.

Ofer Cohen said:
Combine all three rows into one

xDeveloperName = DLookup("DeveloperName", "qryBill","[Vault No] = " &
[Forms]![FrmReleaseOffsite]![xVaultNo])

--
Good Luck
BS"D


williamr said:
Ofer Hi again. After this project - I quit!! Could you please look at this &
tell me what I'm doing wrong. The query opens, the filter works, but the
message box says the same thing, that xDeveloperName = 127 and xvaultNo = 0

Thanks An Advance
Wm

DoCmd.OpenQuery "qryBill"
DoCmd.ApplyFilter , "[Vault No] = " & [Forms]![FrmReleaseOffsite]![xVaultNo]
xDeveloperName = DLookup("DeveloperName", "qryBill")

Ofer Cohen said:
No, you don't need to specify the table name, unless the field you are
looking for is located on more then one table in the query, and they are both
list there as the output of the query.

--
Good Luck
BS"D


:

Ofer, Thank you for your help! The query has 4 related tables, do I have to
specify which table because The information it stores and the information I'm
looking at on the query differ

:

How many records return from the query?

If only one record is returned, you can use

xEmp = DLookUp("EmployeeId","QueryName")

If more then one record returns from the query, you need to add a filter to
the DlookUp using a value such a key field

xEmp = DLookUp("EmployeeId","QueryName","KeyField=" & KeyField)


--
Good Luck
BS"D


:

I have a query that filters out a record, there are fields I want to capture
in variables from the query. I Dim xEmp as string and after the query runs,
I say xEmp = EmployeeId where EmployeeId is a field in the query but I get
nothing. Can someone help me?

Thanks In Advance
 
AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 
AUTO-REPLY From George Levitt

Please allow this to confirm a system receipt of your e-mail.

I am out of the office until Wednesday morning (1/12/05) and will not be
reviewing or responding to email or voicemail until that time.

I look forward to replying to your message on Wednesday.

Thanks and warmest regards, George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top