473,883 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dlookup function just pick the first record ?

12 New Member
Hello to All Expert.
I'm new in here and need your help.
I have 2 tables Models and ProdReport. I have form name ProductsReport. I made Dlookup function in Model drop down to seclect model from table Models. I would like to have right Revision in Models table will pick up to insert in field Firmware section in the form ProuctsReport.
Here is my work.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Model_AfterUpdate()
  2.  
  3. Firmware = DLookup("[Revision]", "[Models]", _
  4.     "[ModelID]= [ModelID]")
  5.  
  6. End Sub
the probem is it just pick the first on table Models only.
I don't know how to fix it.
Plesae help !!!
Thanks in advance.

I put attachment for your review.
Thanks again
Feb 7 '13
26 17644
Seth Schrock
2,965 Recognized Expert Specialist
What exactly are you wanting the criteria to do? For example, are you trying to find the Revision based on a the value selected in a control or you using a variable that contains the value you are searching by?
Feb 8 '13 #11
mayskys1999
12 New Member
I would like to do like this.
whenever I pick up a model from cmb_SelectModel ID_AfterUpdate( )
It will take right Revision from Models table to put in Firmware of ProductsReport form.
Thanks for your support.
Feb 8 '13 #12
Seth Schrock
2,965 Recognized Expert Specialist
Okay, that is helpful to know. For ease, we will do as Z suggested and make the criteria be a string like so:
Expand|Select|Wrap|Line Numbers
  1. dim strWhere as string
  2.  
  3. strWhere = "ModelID = " & Me.cmb_SelectModelID
  4. Debug.Print strWhere
  5.  
  6. Firmware = DLookup("Revision", "Models", strWhere)
Now make sure that the immediate window is open (Ctrl + G will open it if it isn't already) and then change the value in cmb_SelectModel ID to trigger the AfterUpdate event. If this works then great. If not, we need to see the value that got entered in the immediate window.

Something that I just noticed, your original post says that it is in the Model_AfterUpda te event, not the cmb_SelectModel ID_AfterUpdate event. Please verify which one is correct.
Feb 8 '13 #13
mayskys1999
12 New Member
I used your code to my project.
I try to use cmb_SelectModel ID_AfterUpdate.
the immediate window showing ModelID = CCC when I picked the third model.
Feb 8 '13 #14
Seth Schrock
2,965 Recognized Expert Specialist
Okay. In table Models, what is the data type for ModelID?
Feb 8 '13 #15
mayskys1999
12 New Member
Seth,

ModelID is PK data.
Feb 8 '13 #16
Seth Schrock
2,965 Recognized Expert Specialist
A PK could be either Text or Number (Integer, Long Integer or Auto Number). I have gotten in the habbit of always using Long Integer for my PKs, but I just need to know what yours is.
Feb 8 '13 #17
mayskys1999
12 New Member
Seth,
those are Number.
Feb 8 '13 #18
mayskys1999
12 New Member
I'm sorry.

that is Auto Number.
Feb 8 '13 #19
Seth Schrock
2,965 Recognized Expert Specialist
Okay. We now have the source of the problem. The combo box is passing a text string to the criteria and there is a mismatch between the number and the text string.

What you need to do is go to your cmb_SelectModel ID combo box and edit it's row source. It needs to contain the PK of the table that is providing the values and be bound to that field so that it can pass the number to the criteria. What is the current Row Source and Row Source Type of your combo box?
Feb 8 '13 #20

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

Similar topics

2
2291
by: Bob Whisnant | last post by:
In Access 2000, I'm using the DoCmd.TransferText to import a tab delimited .txt file into my database. I'm using a specification file to set field names and data type. The HasFieldNames argument is left blank so this should pick up the first record. But, it don't. It drops the first record. Anyone see what I am doing wrong? Any constructive feedback is much appreciated. Thanks.
1
3196
by: John Hargrove | last post by:
I am building a database to manage test samples in an environmental laboratory. I am learning Access as I go and don't know much about the programming aspects. I hope to make the application user-friendly for the sample login people by populating form controls. Using the DLookup function, I am able to populate a form control in one record using table data. I want to be able to populate multiple records of a subform control (test...
2
14946
by: Ronny Sigo | last post by:
Hello all, I already put the same question, only now I have more to tell ... Although I used this code before in the same routine (only the fieldname of the table differs) ___ at this point in the code I get the error "You canceled the previous operation" err msg. When clicking on Help I get a white screen. I haven't got the slightest idea what it means .... I pinned down that this error comes from the Dlookup function, because if I put...
2
6300
by: Ini | last post by:
Hi, Is there an easy way to pick at random one record out of a recordset and then leave this recordset? I was thinking about doing a recordcount of the recordset, then find at random the number between 1 and <recordcount> and then move to this record in the recordset. There is a easier way, isn't it?
5
5266
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test box that is populated with the code =subfrm_media_review_sec_party.Form!first_name & " " & subfrm_media_review_sec_party.Form!last_name It works except that when I flip through the names it populates the parent form with the name of what ever...
2
2901
by: jonvan20 | last post by:
I have been having trouble with a simple Dlookup command that was Reccommended to me by a nice fellow named Vic, On the other hand I have statements like this that wont run they give me a run time error Dim QuoteNumber As String QuoteNumber = Me.txtQuoteNumber Me.txtDealerNumber = DLookup("Dealer_Number", "Quote Table", "Quote_Number=" & txtQuoteNumber)
3
1909
by: Birky | last post by:
Can someone please help me with my syntax below? I am trying to enable an object on a form for specific users only and in doing so I am trying to use the DLookUp function to try and keep it sweet and simple. I have created a table named “Employees” where I plan to add the people that will have access to the particular object (named CmdProjReport). The table is very basic just housing the below info: Employees Table: KeyID EmployeeID ...
2
9293
by: Lumpy | last post by:
Hi all, I am having a problem with a line of code in access vba. I am trying to use the DLookup function to check whether or not a record already exists with a dealer name. Once I know if it exists or not, later on in the code I will run some sql to either insert a new record or update an existing record. But, I am getting a syntax error that says I am missing an operator. I have googled around but to no luck, any help would be much...
1
1351
by: Cyprus106 | last post by:
So I've got about a million records that I'm sifting through with a SELECT statement. Right now I've been saying SELECT * FROM MYTABLE WHERE MYFIELD='GUIDE'... But I only want the first record it finds that matches the criteria. I thoguht it was SELECT FIRST but I was wrong. I know this is awfulyl simple, but I can't find tha answer!! Any help is much appreciated! Thanks!
5
5148
by: nandithadevaraj | last post by:
Hi, I am working on oracle, frankly speaking till nw i have nt worked in oracle i need help please help me out in this actually i have written query using DLOOKUP function as DLOOKUP function is not supported in oracle how can i change that to other function. is there any function to convert???? i wil include the dllokup function also
0
9781
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11121
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10734
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10836
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9564
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7960
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5982
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4210
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3230
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.