473,385 Members | 1,893 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,385 software developers and data experts.

Problems with DLookUp

283 100+
Hello,

Im trying to use the DLookup function to fill in a few text boxes based on the criteria of 3 text boxes. I think I have the vba code right but for some reason its not working.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Me.Text1 = DLookup("[PlaceName]","MainTable","[Date]=" _ & Forms![EditForm]!Text3, _ 
  3. "[Name]=" & Forms![EditForm]![Text4, 
  4. "[Number]=" & Forms![EditForm]!Text5)
  5.  
  6.  
What im trying to do is have the text1 box display a value from the MainTable based on what is in text3, 4, and 5.

Appreciate any help with this

Thanks :)
Sep 27 '10 #1

✓ answered by MikeTheBike

Hi

On the basis that Text1, Text3, Text4 and Text5 are all in the same form and Text3 is a date, Text4 is Text and Text5 is numeric, the I suggest this should do it
Expand|Select|Wrap|Line Numbers
  1. Me.Text1 = DLookup("[PlaceName]", "MainTable", _
  2.     "[Date]=#" & Format(Text3, "mm/dd/yy") & "# " & _
  3.     "And [Name]= '" & Text4 & "' " & _
  4.     "And [Number]= " & Text5)
The date should be delimited with # symbols and formatted in US format, and the Text arguments should be delimited with apostrophies.

HTH

MTB

3 3066
MikeTheBike
639 Expert 512MB
Hi

On the basis that Text1, Text3, Text4 and Text5 are all in the same form and Text3 is a date, Text4 is Text and Text5 is numeric, the I suggest this should do it
Expand|Select|Wrap|Line Numbers
  1. Me.Text1 = DLookup("[PlaceName]", "MainTable", _
  2.     "[Date]=#" & Format(Text3, "mm/dd/yy") & "# " & _
  3.     "And [Name]= '" & Text4 & "' " & _
  4.     "And [Number]= " & Text5)
The date should be delimited with # symbols and formatted in US format, and the Text arguments should be delimited with apostrophies.

HTH

MTB
Sep 27 '10 #2
slenish
283 100+
Hi MTB,

Thanks so much for the reply. I think what you wrote is what I needed I adjusted it a little bit playing around with it because at first I was getting some errors. Now im not getting any errors but im not getting any results?? Any ideas? Also to let you know both Text4 and Text 5 are numbers but they are being entered and saved as a string.

Thanks again

Here is what the readjustment looks like

Expand|Select|Wrap|Line Numbers
  1.  
  2. Me.Text1 = DLookup("[Name]", "MainTable", _
  3.     "[Date]=#" & Format(Text3, "mm/dd/yy") & "# " & _
  4.     "And [Number]=" & Format(Text4, "'") & _
  5.     "And [Number2]=" & Format(Text5, "'"))
  6.  
  7.  
Sep 27 '10 #3
slenish
283 100+
Haha I just got it to work. I had to readjust the format for the text 4 and 5 and it works great!

thanks again MTB could not have done it with out you :D

here is what I did

Expand|Select|Wrap|Line Numbers
  1.  
  2. Me.Text1 = DLookup("[Name]", "MainTable", _
  3.     "[ProcessDate]=#" & Format(Text3, "mm/dd/yy") & "# " & _
  4.     "And [Number]=" & Chr(34) & Text4 & Chr(34) & _
  5.     "And [Number2]=" & Chr(34) & Text5 & Chr(34))
  6.  
  7.  
Sep 27 '10 #4

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

Similar topics

2
by: Ronny Sigo | last post by:
Hello all, I want to perform a DLookup function with a variable (long) as critera. I know if it was a string this would be the correct syntax : Me!txtStad.Value = DLookup("", "tblPostnummers", " =...
5
by: Kalvin Schroder | last post by:
I am fairly new to Access, and am trying to put together an invoice form. The main form in called InvoiceDetailFm. Source is the table InvoiceDetail and has invoice number, saleman, and CustID as...
0
by: Tony Williams | last post by:
I have posted a number of posts in the Access newsgroups concerning my problem with DLookup. I have had a number of the experts with helpful suggestions but I still can't get it to work! This is...
3
by: Tempy | last post by:
Hi all, i am running into problems with a DLookUp below: =DLookUp("","tblBuyerTotals"," =' " & me!LastName) This is in the Control Source of a text box on the same form. "LastName" is a text...
6
by: WWH | last post by:
New to Access and have what should be a simple problem. Have two tables... 1. first table has description of herbs and Chapter+Section number (ie 2.3 - decimal) 2. second table has same...
2
by: sfrvn | last post by:
I am embarrassed to say I cannot make this work. Recently upgraded to Access 2003, but do not know if that part of problem (AKA 'syntax change'). Would someone be kind enough to lead me by the...
3
by: stumo | last post by:
Hi I'm fairly new to access and as such my experience of VBA is somewhat limited. I have a login form which is linked to an "employees table" which asks for users to enter their name and...
2
by: David | last post by:
Dear All I'm trying to use a multi-select listbox as criteria to either add new record or edit the current record of the destiantation table with each row selected in the box. This works fine...
6
by: Tomino | last post by:
Hi, I am working on a log in form for an Access 2003 db. Because the built-in jet database engine doesn't supply the ability to record every log attempt, failed attempt, validate passwords, user...
0
by: solargovind | last post by:
Hello, I have few problem with Dlookup condition. I need to retrieve next record or previous record based on certain condition. The conditions are set in in the combo box. Here, I am trying to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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
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,...
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...

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.