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. -
-
Me.Text1 = DLookup("[PlaceName]","MainTable","[Date]=" _ & Forms![EditForm]!Text3, _
-
"[Name]=" & Forms![EditForm]![Text4,
-
"[Number]=" & Forms![EditForm]!Text5)
-
-
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 :)
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 - Me.Text1 = DLookup("[PlaceName]", "MainTable", _
-
"[Date]=#" & Format(Text3, "mm/dd/yy") & "# " & _
-
"And [Name]= '" & Text4 & "' " & _
-
"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
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 - Me.Text1 = DLookup("[PlaceName]", "MainTable", _
-
"[Date]=#" & Format(Text3, "mm/dd/yy") & "# " & _
-
"And [Name]= '" & Text4 & "' " & _
-
"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
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 -
-
Me.Text1 = DLookup("[Name]", "MainTable", _
-
"[Date]=#" & Format(Text3, "mm/dd/yy") & "# " & _
-
"And [Number]=" & Format(Text4, "'") & _
-
"And [Number2]=" & Format(Text5, "'"))
-
-
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 -
-
Me.Text1 = DLookup("[Name]", "MainTable", _
-
"[ProcessDate]=#" & Format(Text3, "mm/dd/yy") & "# " & _
-
"And [Number]=" & Chr(34) & Text4 & Chr(34) & _
-
"And [Number2]=" & Chr(34) & Text5 & Chr(34))
-
-
Sign in to post your reply or Sign up for a free account.
Similar topics
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", " =...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
| |