DLookUp on Forms

A

AccessUser777

Hi all,
I'm needing some assistance in making this DLookUp function work for me. I
have two tables (tblReship and dbo_dailyrecords). I built a form based on
tblReships but I need to populate some fields on the form with data from
dbo_dailyrecords. I looked at this site and got some coding on using the
DLookUp function and below is the code I'm using:

Private Sub TaskID_AfterUpdate()
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("SELECT*From dbo.dailyrecords WHERE
ORIGINALTASKID=" & Me.TaskID)
If Not (rst.EOF And rst.BOF) Then
'/now populate the textboxes
Me.CallDate = rst("Date_Created")
End If

Set rst = Nothing
End Sub

When I enter a task id (textbox) I get an error message:
Run Time Error '3024'

What am I missing in the code? Any help/suggestion/advice would be greatly
appreciated. Thanks
 
K

Klatuu

That is not a DLookup. It is recordset processing. The DLookup will only
return one value, not a record. DLookup is actually a function used to find
the value of a field in a domain (recordset) based on some criteria.

I would consider using a subform in this case to show the record from daily
data.
 
J

J_Goddard via AccessMonster.com

Hi -

In your select statement - dbo.dailyrecords should be dbo_dailyrecords, if I
read your post correctly.

John
 
B

Beetle

Dave is right, but the reason you are getting the Runtime error 3024 is
probably because of this line;

("SELECT*From dbo.dailyrecords WHERE ORIGINALTASKID=" & Me.TaskID)

You have a table named dbo_dailyrecords, but in the above statement you
added a period to the name, which your SQL statement is interpreting as
a table name followed by a field name. In other words, it is looking for a
table named dbo and a field named dailyrecords within that table.
 
A

AccessUser777 via AccessMonster.com

Beetle said:
Dave is right, but the reason you are getting the Runtime error 3024 is
probably because of this line;

("SELECT*From dbo.dailyrecords WHERE ORIGINALTASKID=" & Me.TaskID)

You have a table named dbo_dailyrecords, but in the above statement you
added a period to the name, which your SQL statement is interpreting as
a table name followed by a field name. In other words, it is looking for a
table named dbo and a field named dailyrecords within that table.
Hi all,
I'm needing some assistance in making this DLookUp function work for me. I
[quoted text clipped - 20 lines]
What am I missing in the code? Any help/suggestion/advice would be greatly
appreciated. Thanks



HI all...thanks very much for the advice. I've since changed the peroiod to
an underscore but now I get Run Time Error 3464 "data type mismatch"...which
I don't understand. both fields on both tables are set as date/time fields?..
.any thoughts?
 
A

AccessUser777 via AccessMonster.com

Beetle said:
Dave is right, but the reason you are getting the Runtime error 3024 is
probably because of this line;

("SELECT*From dbo.dailyrecords WHERE ORIGINALTASKID=" & Me.TaskID)

You have a table named dbo_dailyrecords, but in the above statement you
added a period to the name, which your SQL statement is interpreting as
a table name followed by a field name. In other words, it is looking for a
table named dbo and a field named dailyrecords within that table.
Hi all,
I'm needing some assistance in making this DLookUp function work for me. I
[quoted text clipped - 20 lines]
What am I missing in the code? Any help/suggestion/advice would be greatly
appreciated. Thanks



HI all...thanks very much for the advice. I've since changed the peroiod to
an underscore but now I get Run Time Error 3464 "data type mismatch"...which
I don't understand. both fields on both tables are set as date/time fields?..
.any thoughts?
 
A

AccessUser777 via AccessMonster.com

Beetle said:
Dave is right, but the reason you are getting the Runtime error 3024 is
probably because of this line;

("SELECT*From dbo.dailyrecords WHERE ORIGINALTASKID=" & Me.TaskID)

You have a table named dbo_dailyrecords, but in the above statement you
added a period to the name, which your SQL statement is interpreting as
a table name followed by a field name. In other words, it is looking for a
table named dbo and a field named dailyrecords within that table.
Hi all,
I'm needing some assistance in making this DLookUp function work for me. I
[quoted text clipped - 20 lines]
What am I missing in the code? Any help/suggestion/advice would be greatly
appreciated. Thanks



HI all...thanks very much for the advice. I've since changed the peroiod to
an underscore but now I get Run Time Error 3464 "data type mismatch"...which
I don't understand. both fields on both tables are set as date/time fields?..
.any thoughts?
 
A

AccessUser777 via AccessMonster.com

Beetle said:
Dave is right, but the reason you are getting the Runtime error 3024 is
probably because of this line;

("SELECT*From dbo.dailyrecords WHERE ORIGINALTASKID=" & Me.TaskID)

You have a table named dbo_dailyrecords, but in the above statement you
added a period to the name, which your SQL statement is interpreting as
a table name followed by a field name. In other words, it is looking for a
table named dbo and a field named dailyrecords within that table.
Hi all,
I'm needing some assistance in making this DLookUp function work for me. I
[quoted text clipped - 20 lines]
What am I missing in the code? Any help/suggestion/advice would be greatly
appreciated. Thanks



HI all...thanks very much for the advice. I've since changed the peroiod to
an underscore but now I get Run Time Error 3464 "data type mismatch"...which
I don't understand. both fields on both tables are set as date/time fields?..
.any thoughts?
 
A

AccessUser777 via AccessMonster.com

Beetle said:
Dave is right, but the reason you are getting the Runtime error 3024 is
probably because of this line;

("SELECT*From dbo.dailyrecords WHERE ORIGINALTASKID=" & Me.TaskID)

You have a table named dbo_dailyrecords, but in the above statement you
added a period to the name, which your SQL statement is interpreting as
a table name followed by a field name. In other words, it is looking for a
table named dbo and a field named dailyrecords within that table.
Hi all,
I'm needing some assistance in making this DLookUp function work for me. I
[quoted text clipped - 20 lines]
What am I missing in the code? Any help/suggestion/advice would be greatly
appreciated. Thanks



HI all...thanks very much for the advice. I've since changed the peroiod to
an underscore but now I get Run Time Error 3464 "data type mismatch"...which
I don't understand. both fields on both tables are set as date/time fields?..
..any thoughts?
 
A

AccessUser777 via AccessMonster.com

AccessUser777 said:
Dave is right, but the reason you are getting the Runtime error 3024 is
probably because of this line;
[quoted text clipped - 11 lines]
HI all...thanks very much for the advice. I've since changed the peroiod to
an underscore but now I get Run Time Error 3464 "data type mismatch"...which
I don't understand. both fields on both tables are set as date/time fields?..
.any thoughts?


Sorry for the many replies, didn't know if it had posted until I checked it..
 
T

Tom Lake

AccessUser777 via AccessMonster.com said:
Beetle wrote:
HI all...thanks very much for the advice. I've since changed the peroiod to
an underscore but now I get Run Time Error 3464 "data type mismatch"...which
I don't understand. both fields on both tables are set as date/time fields?..
any thoughts?

You could try this:

("SELECT*From dbo.dailyrecords WHERE ORIGINALTASKID= #" & Me.TaskID & "#")

Tom Lake
 

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