By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,662 Members | 1,765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,662 IT Pros & Developers. It's quick & easy.

Dlookup - Place value in an unbound textbox

Nathan H
100+
P: 104
I don't know why I am having an issue with this, especially when I helped someone the other day.

Four fields in the table tblFTPLOGIN:
txtServerList
txtFolder
txtUID
txtPWD

The unbound form has a combo box called txtServerChoice, listing txtServerList from the table. I want to post txtFolder from the table to an unbound box txt on form frmForm.

Expand|Select|Wrap|Line Numbers
  1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "[txtServerList]" = Forms![frmForm]![txtServerChoice])
  2.  

This does not work either
Expand|Select|Wrap|Line Numbers
  1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "txtServerList = " & Forms![frmForm]![txtServerChoice])
  2.  
The thing does not work...frustrating
Dec 21 '07 #1
Share this Question
Share on Google+
3 Replies


Denburt
Expert 100+
P: 1,356
Try this:

Expand|Select|Wrap|Line Numbers
  1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "txtServerList = '" & Forms![frmForm]![txtServerChoice] & "'")
  2.  
Or an easier possibly quicker or faster(for MS Access) method would be to list the txtfolder alongside the txtserverlist in the combobox and reference it like so:

me!txt1 = me!txtServerChoice.column(2)
Dec 21 '07 #2

Nathan H
100+
P: 104
Try this:

Expand|Select|Wrap|Line Numbers
  1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "txtServerList = '" & Forms![frmForm]![txtServerChoice] & "'")
  2.  
Or an easier possibly quicker or faster(for MS Access) method would be to list the txtfolder alongside the txtserverlist in the combobox and reference it like so:

me!txt1 = me!txtServerChoice.column(2)

Denburt...that worked great!.

Expand|Select|Wrap|Line Numbers
  1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "txtServerList = '" & Forms![frmForm]![txtServerChoice] & "'")
  2.  
Can you throw me a quick note why that worked?:)
Dec 21 '07 #3

Denburt
Expert 100+
P: 1,356
Denburt...that worked great!.

Expand|Select|Wrap|Line Numbers
  1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "txtServerList = '" & Forms![frmForm]![txtServerChoice] & "'")
  2.  
Can you throw me a quick note why that worked?:)
Yes I would be glad to.
When using text in criteria you have to wrap it in quotes, a number type you don't, so your example would be fine if it was a number but since it was text, you needed to add an extra set of quotes:
txtServerList = "MyText"

So since your wrapping the expression in quotes already you need to essentially double wrap or use single quotes (the way I did). I hope that was clear.

Glad it's working if you need anything else (more examples etc.) let me know.
Dec 21 '07 #4

Post your reply

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