473,394 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Dlookup

9
I have tried several ways to make the dlookup work on a form I have in my database and it is not returning any results any help would be appreciated.

I have a table (tblWorkRequest)with the following fields ID (PK), WorkOrderNo, RequestDate, RequestedBy, Location, Description, AssignedTo, ScheduledCompletionDate, and ActualCompletionDate.

I have two forms (frmWorkRequest and frmAssignWorkRequest).

frmWorkRequest has the follow fields txtWorkOrderNo, txtRequestDate, txtRequestedBy, txtLocation and txtDescription.

frmAssignWorkRequest has the following fields cboWorkOrderNo, txtRequestDate, txtRequestedBy, txtLocation, txtDescription, txtAssignedTo, txtScheduledCompletionDate and txtActualCompletionDate.

I want a user to be able to choose from the cboWorkOrderNo list on the AssignWorkRequest form and that the follow fields would populate txtRequestDate, txtRequestedBy, txtLocation, txtDescription and then they would enter information into the other boxes and it would be added to that record in the WorkRequest table.

This is the code I have so far.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboWorkOrderNo_AfterUpdate()
  2. txtRequestDate = DLookup("RequestDate", "WorkRequest", "WorkOrderNo = " & Me.cboWorkOrderNo)
  3. txtRequestedBY = DLookup("RequestedBy", "WorkRequest", "WorkOrderNo = " & Me.cboWorkOrderNo)
  4. txtLocation = DLookup("Location", "WorkRequest", "WorkOrderNo = " & Me.cboWorkOrderNo)
  5. txtDescriptionOfWork = DLookup("DescriptionOfWork", "WorkRequest", "WorkOrderNo = " & Me.cboWorkOrderNo)
  6. End Sub
Any help would be appreciated.
Feb 28 '14 #1
3 1044
mcupito
294 256MB
Are you using Parent / Child forms? (Subforms)

Also, is WorkOrderNo unique for every row?

Personally, I would create a query and stick it in VBA on the AfterUpdate event of the Combobox or Button Click event to open up (or show) the other form. I would make that query the data source for the form you want the values to show up on, and tie in the correct information onto the form.
Then, use the fields you already have in conjunction with the fields you want the user to enter in and insert the necessary information.

You can use the combobox as a filter in the WHERE clause, like you do for you DLookUp().


Before all of that, though. Try running your DLookUps in a SELECT query to see what results you're returning.
Feb 28 '14 #2
Rabbit
12,516 Expert Mod 8TB
First, your database in unnormalized, you are repeating a bunch of information that is unnecessary. You can read more about normalization in our article here: http://bytes.com/topic/access/insigh...ble-structures

Second, is the work order number a string field? If it is, you need to surround the value in quotes.
Feb 28 '14 #3
NeoPa
32,556 Expert Mod 16PB
I suspect Rabbit's second point is the answer you need.

Nevertheless, the first point is more important and will help you more in the long run if you take it to heart.

PS. Remember to set Best Answer when you've checked out his suggestion.
Mar 1 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: KLAU | last post by:
I have a field that retrieves information from an expression in a query. I have used a DLookup function to get the calculated field from the query. However, the relationship is 1-to-many so one...
6
by: JLM | last post by:
What am I missing here? I have a form where I enter a "Class Code". This value corresponds to what sits in table "class code descriptions" along with the "title" of each "class code." Key...
4
by: MLH | last post by:
I have tried using DLookUp in this manner... If DLookUp("","tblClients","='2021234567'") Then MsgBox "Found it!" End If I am wondering if that is a misuse of the DLookUp command? Type...
2
by: ctyrrell | last post by:
I have read with interest the many discussions of the 3048 Error: Cannot open any more databases. I understand how the number of open Table ID's causes the problem. My question has to do with the...
8
by: Christine Henderson | last post by:
I have a problem using the above function in the following simplified circumstance: In the lookup table called "Klms Travelled" I have 3 fields, eg: Receiver Name Receiver Suburb ...
11
by: MLH | last post by:
DLookup("", "tblPreliminaryVINs", "=Forms!frmVINODO!SerialNum") is giving me a Type Mismatch error. That's confusing to me and I don't know how to circumvent it. The field in...
2
by: Don | last post by:
Can someone help me fix my DLookup problem. I'm far from proficiency with Access. I've been creating databases for several years for work with the help of many of you and trial and error. I have...
9
by: | last post by:
In my database I have a 'control table' in which basic info is stored about the application, for instance the application's path and the name of the company that is using it. In all of the...
15
by: rleepac | last post by:
This is a little complicated but I'll do my best to explain. In my db I have a table called L_AgeCorrection which has the following fields: Age, Sex, Frequency, AgeValue This is a table used to...
8
by: JDaly | last post by:
This bombs on the StPL= line. I want it to look up a string value from a table with a criterion of matching another string. In immediate mode the form evaluates correctly with ? Form!! as TEST but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.