Tags: access, database, dlookup, especially, fields, microsoft, mysql, oracle, sql, table, textbox, unbound, value

Dlookup - Place value in an unbound textbox

On Database » Microsoft Access

2,626 words with 3 Comments; publish: Fri, 04 Jan 2008 23:54:00 GMT; (250328.13, « »)

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.

Code: ( vb )

  1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "[txtServerList]" = Forms![frmForm]![txtServerChoice])

This does not work either

Code: ( vb )

  1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "txtServerList = " & Forms![frmForm]![txtServerChoice])

The thing does not work...frustrating

All Comments

Leave a comment...

  • 3 Comments
    • Try this:

      Code: ( vb )

      1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "txtServerList = '" & Forms![frmForm]![txtServerChoice] & "'")

      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)

      #1; Fri, 04 Jan 2008 23:55:00 GMT
    • Quote:=== Original Words ===

      DenburtTry this:

      Code: ( vb )

      1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "txtServerList = '" & Forms![frmForm]![txtServerChoice] & "'")

      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!.

      Code: ( vb )

      1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "txtServerList = '" & Forms![frmForm]![txtServerChoice] & "'")

      Can you throw me a quick note why that worked?:)

      #2; Fri, 04 Jan 2008 23:56:00 GMT
    • Quote:=== Original Words ===

      Nathan HDenburt...that worked great!.

      Code: ( vb )

      1. txt1.Value = DLookup("[txtFolder]", "tblFTPLOGIN", "txtServerList = '" & Forms![frmForm]![txtServerChoice] & "'")

      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.

      #3; Fri, 04 Jan 2008 23:57:00 GMT