Results 1 to 7 of 7

Thread: Unbound form

  1. #1
    Join Date
    Jul 2009
    Posts
    185

    Question Unanswered: Unbound form

    I have a unbound form for adding.
    I have a combo box to select my plane id which works. Next to it I have a test field that I want the planes description what do I do to get the slected plane's description?

  2. #2
    Join Date
    May 2005
    Posts
    1,191
    If it's just a once off lookup, have a see at the Dlookup() function (or better yet the Elookup() function).
    Me.Geek = True

  3. #3
    Join Date
    Jul 2009
    Posts
    185

    Question

    DLookup works great. But now how do I enter this data to my unbound text field.
    Me.spdrcription doesn't work so how do I refer to this field. Also my field show "#Name? when I open it. Also how do I get the return of my combo box for my dlookup command?
    I believe these to be newbie questions but my book doesn't seem to give any examples. I have 6 books coming from my library so I hope one of them will help!!


    Private Sub Combo8_AfterUpdate()
    txtdescription = DLookup("spdescription", "planes", "planes.id=2")
    MsgBox "Dlookup=" & txtdescription
    Me.spDescription = txtdescription
    End Sub

  4. #4
    Join Date
    May 2005
    Posts
    1,191
    You'll need to build the string dynamically, like:

    Code:
    Private Sub Combo8_AfterUpdate()
    
        Me.spDescription = DLookup("spdescription", "planes", "planes.id=" & me.cboName)
    
    End Sub
    Me.Geek = True

  5. #5
    Join Date
    Jul 2009
    Posts
    185
    I now understand that. But
    Me.spDescription = txtdescription don't seem to work.
    How do you reference a current forms field name?

  6. #6
    Join Date
    Jul 2009
    Posts
    185
    I just discovered that I can get my planes description from the combobox select.
    MsgBox "Combo=" & Me.Combo8.Column(1)
    Me.spDescription = Me.Combo8.Column(1)
    The msgbox works fine but the "Me.spDescription = Me.Combo8.Column(1)"
    gives me a "You can't assign a value to this object."

  7. #7
    Join Date
    Jul 2009
    Posts
    185

    Thumbs up

    I finally got this fixed I had one space in the control source property. Finally after seraching the next for #name? I found the problem. Getting rid of the #Name? in the field fixed the problem.

    Thanks all for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •