DLookup problem.

  • Thread starter Thread starter Linda
  • Start date Start date
L

Linda

I'm getting a type mismatch error when trying to run the
following:

lngpropid = DLookup
("[PropID]", "tblTenantsinSplitBillArchive", "[PropID]
= " & cbokeynr.Column(1) And [DateInvoice] = "#" &
dteinvoice & "#")

Does anyone see what the problem is? Thanks!
 
Suggestions:

1. The 3rd argument is malformed. Try:
Dim strWhere As String
strWhere = "[PropID] = " & cbokeynr.Column(1) & " AND [DateInvoice] = #" &
dteinvoice & "#"
lngpropid = DLookup("[PropID]", "tblTenantsinSplitBillArchive", strWhere)

2. Assuming "cbokeynr" is a combo, check its RowSource. What is the data
type of the field in the 2nd column (because the first column is column 0)?
If it is a Text field, and PropID is a Number, you have a mismatch. If they
are both Text fields, you need extra quotes, i.e.:
strWhere = "[PropID] = """ & cbokeynr.Column(1) & """ AND [DateInvoice] = #"
& dteinvoice & "#"

3. DLookup() could return a Null if the result is not found. If "lngpropid"
is a Long, that won't work.
 
Great it works!! Thanks very much Allen I appreciate it!
-----Original Message-----
Suggestions:

1. The 3rd argument is malformed. Try:
Dim strWhere As String
strWhere = "[PropID] = " & cbokeynr.Column(1) & " AND [DateInvoice] = #" &
dteinvoice & "#"
lngpropid = DLookup
("[PropID]", "tblTenantsinSplitBillArchive", strWhere)
2. Assuming "cbokeynr" is a combo, check its RowSource. What is the data
type of the field in the 2nd column (because the first column is column 0)?
If it is a Text field, and PropID is a Number, you have a mismatch. If they
are both Text fields, you need extra quotes, i.e.:
strWhere = "[PropID] = """ & cbokeynr.Column(1) & """ AND [DateInvoice] = #"
& dteinvoice & "#"

3. DLookup() could return a Null if the result is not found. If "lngpropid"
is a Long, that won't work.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

I'm getting a type mismatch error when trying to run the
following:

lngpropid = DLookup
("[PropID]", "tblTenantsinSplitBillArchive", "[PropID]
= " & cbokeynr.Column(1) And [DateInvoice] = "#" &
dteinvoice & "#")

Does anyone see what the problem is? Thanks!


.
 

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

Similar Threads

Nested query problem 6
Passing null values in a Querystring 1
Dictionary By Reference 4
DLookup Problem 2
Dlookup error 13 7
How to determine the begindate of previous month 2
dlookup 2
DLookup Error 7

Back
Top