Dlookup in a form

P

Patti

Hi!

I'm trying to autofill a form using Dlookup and it's not
working. The controlling field is cmbRFCE. In the
AfterUpdate field, I have the following:

Private Sub cmbRFCE__AfterUpdate()
[cmbProject] = DLookup("[Project]", "tblRFCE", "[RFCE]=" &
[Forms]![PO]![cmbRFCE])
[cmbDept] = DLookup("[Dept]", "tblRFCE", "[RFCE]=" &
[Forms]![PO]![cmbRFCE])

End Sub

It doesn't give me any errors, but the cmbProject and
cmbDept fields don't populate. In those combo boxes, the
rowsourcetype is set to Table/query and the row source is
a query: SELECT tblRFCE.[Project] FROM tblRFCE WHERE
(((tblRFCE.[RFCE])=[Forms]![PO]![cmbRFCE])); The Dept
combo box has the same query but it selects tblRFCE.[Dept]

What am I doing wrong?
 
R

Reggie

Patti, Instead of doing a DLookUp, since you already have a query/sql statement that will return the
results you want just requery those controls in the AfterUpdate event:

Private Sub cmbRFCE__AfterUpdate()
Me.[cmbProject].Requery
Me.[cmbDept] .Requery
End sub

Hope I understood correctly and that this helps.
 
P

Patti

Hi Reggie,

It's still not working. No error, but no data -- just
headers! Since it's pulling the headers, I assume it's
reading the right field in the table, but it's not
recognizing the matching field with cmbRFCE. Any ideas?
-----Original Message-----
Patti, Instead of doing a DLookUp, since you already have
a query/sql statement that will return the
results you want just requery those controls in the AfterUpdate event:

Private Sub cmbRFCE__AfterUpdate()
Me.[cmbProject].Requery
Me.[cmbDept] .Requery
End sub

Hope I understood correctly and that this helps.

--
Reggie

----------
Hi!

I'm trying to autofill a form using Dlookup and it's not
working. The controlling field is cmbRFCE. In the
AfterUpdate field, I have the following:

Private Sub cmbRFCE__AfterUpdate()
[cmbProject] = DLookup("[Project]", "tblRFCE", "[RFCE] =" &
[Forms]![PO]![cmbRFCE])
[cmbDept] = DLookup("[Dept]", "tblRFCE", "[RFCE]=" &
[Forms]![PO]![cmbRFCE])

End Sub

It doesn't give me any errors, but the cmbProject and
cmbDept fields don't populate. In those combo boxes, the
rowsourcetype is set to Table/query and the row source is
a query: SELECT tblRFCE.[Project] FROM tblRFCE WHERE
(((tblRFCE.[RFCE])=[Forms]![PO]![cmbRFCE])); The Dept
combo box has the same query but it selects tblRFCE. [Dept]

What am I doing wrong?


.
 
P

Patti

Well I just got it to work. I set the bound column to 1
on cmbRFCE. That did the trick but I don't know why! I
haven't quite figured out what "bound columns" means!
-----Original Message-----
Hi Reggie,

It's still not working. No error, but no data -- just
headers! Since it's pulling the headers, I assume it's
reading the right field in the table, but it's not
recognizing the matching field with cmbRFCE. Any ideas?
-----Original Message-----
Patti, Instead of doing a DLookUp, since you already
have
a query/sql statement that will return the
results you want just requery those controls in the AfterUpdate event:

Private Sub cmbRFCE__AfterUpdate()
Me.[cmbProject].Requery
Me.[cmbDept] .Requery
End sub

Hope I understood correctly and that this helps.

--
Reggie

----------
Hi!

I'm trying to autofill a form using Dlookup and it's not
working. The controlling field is cmbRFCE. In the
AfterUpdate field, I have the following:

Private Sub cmbRFCE__AfterUpdate()
[cmbProject] = DLookup("[Project]", "tblRFCE", "[RFCE] =" &
[Forms]![PO]![cmbRFCE])
[cmbDept] = DLookup("[Dept]", "tblRFCE", "[RFCE]=" &
[Forms]![PO]![cmbRFCE])

End Sub

It doesn't give me any errors, but the cmbProject and
cmbDept fields don't populate. In those combo boxes, the
rowsourcetype is set to Table/query and the row source is
a query: SELECT tblRFCE.[Project] FROM tblRFCE WHERE
(((tblRFCE.[RFCE])=[Forms]![PO]![cmbRFCE])); The Dept
combo box has the same query but it selects tblRFCE. [Dept]

What am I doing wrong?


.
.
 
B

berk

The original way you did dLookup refers to a data type
of "number" not "string". So, if the bound field of
combo box you are referring to is a number, then it will
work. If it is not, you have to add some "'"
(apsotrophes) to you code like this:

[cmbDept] = DLookup("[Dept]", "tblRFCE", "[RFCE]='" &
[Forms]![PO]![cmbRFCE] & "'")


-----Original Message-----
Well I just got it to work. I set the bound column to 1
on cmbRFCE. That did the trick but I don't know why! I
haven't quite figured out what "bound columns" means!
-----Original Message-----
Hi Reggie,

It's still not working. No error, but no data -- just
headers! Since it's pulling the headers, I assume it's
reading the right field in the table, but it's not
recognizing the matching field with cmbRFCE. Any ideas?
-----Original Message-----
Patti, Instead of doing a DLookUp, since you already
have
a query/sql statement that will return the
results you want just requery those controls in the AfterUpdate event:

Private Sub cmbRFCE__AfterUpdate()
Me.[cmbProject].Requery
Me.[cmbDept] .Requery
End sub

Hope I understood correctly and that this helps.

--
Reggie

----------
Hi!

I'm trying to autofill a form using Dlookup and it's not
working. The controlling field is cmbRFCE. In the
AfterUpdate field, I have the following:

Private Sub cmbRFCE__AfterUpdate()
[cmbProject] = DLookup
("[Project]", "tblRFCE", "[RFCE]
=" &
[Forms]![PO]![cmbRFCE])
[cmbDept] = DLookup("[Dept]", "tblRFCE", "[RFCE]=" &
[Forms]![PO]![cmbRFCE])

End Sub

It doesn't give me any errors, but the cmbProject and
cmbDept fields don't populate. In those combo
boxes,
the
rowsourcetype is set to Table/query and the row
source
is
a query: SELECT tblRFCE.[Project] FROM tblRFCE WHERE
(((tblRFCE.[RFCE])=[Forms]![PO]![cmbRFCE])); The Dept
combo box has the same query but it selects tblRFCE. [Dept]

What am I doing wrong?


.
.
.
 
P

Patti

Thanks!
-----Original Message-----
The original way you did dLookup refers to a data type
of "number" not "string". So, if the bound field of
combo box you are referring to is a number, then it will
work. If it is not, you have to add some "'"
(apsotrophes) to you code like this:

[cmbDept] = DLookup("[Dept]", "tblRFCE", "[RFCE]='" &
[Forms]![PO]![cmbRFCE] & "'")


-----Original Message-----
Well I just got it to work. I set the bound column to 1
on cmbRFCE. That did the trick but I don't know why! I
haven't quite figured out what "bound columns" means!
-----Original Message-----
Hi Reggie,

It's still not working. No error, but no data -- just
headers! Since it's pulling the headers, I assume it's
reading the right field in the table, but it's not
recognizing the matching field with cmbRFCE. Any ideas?

-----Original Message-----
Patti, Instead of doing a DLookUp, since you already have
a query/sql statement that will return the
results you want just requery those controls in the
AfterUpdate event:

Private Sub cmbRFCE__AfterUpdate()
Me.[cmbProject].Requery
Me.[cmbDept] .Requery
End sub

Hope I understood correctly and that this helps.

--
Reggie

----------
message
Hi!

I'm trying to autofill a form using Dlookup and it's not
working. The controlling field is cmbRFCE. In the
AfterUpdate field, I have the following:

Private Sub cmbRFCE__AfterUpdate()
[cmbProject] = DLookup ("[Project]", "tblRFCE", "[RFCE]
=" &
[Forms]![PO]![cmbRFCE])
[cmbDept] = DLookup("[Dept]", "tblRFCE", "[RFCE]=" &
[Forms]![PO]![cmbRFCE])

End Sub

It doesn't give me any errors, but the cmbProject and
cmbDept fields don't populate. In those combo boxes,
the
rowsourcetype is set to Table/query and the row source
is
a query: SELECT tblRFCE.[Project] FROM tblRFCE WHERE
(((tblRFCE.[RFCE])=[Forms]![PO]![cmbRFCE])); The Dept
combo box has the same query but it selects tblRFCE.
[Dept]

What am I doing wrong?


.

.
.
.
 

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

Top