Results 1 to 4 of 4
  1. #1
    k9drh is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2011
    Posts
    6

    Combo Box Update Form

    I need someone to kick me in the head and work lose some brain cells, please.
    Here’s my problem I have a table call Volunteer and created a simple query qryVolunteer.* and everything shows when executed. I then created a form from the query. Form looks good. Now comes the interesting part. I have used the wizard to create a combo box unbound to fill the form fields with the selected data values from the pop down selection. On other forms I have this default macro works fine. However on this form it doesn’t update the fields with the select data. So I figured I would do it the old fashion way and use VBA. As you can see from the code below I have tried several approaches. In its current form all fields on the form show #NAME? so I added what I thought was correct coding to define exactly what recordset to open and use. The commented out code did not populate any change to the form. The NOMATCH comes back as FALSE so it found the record in the recordset. So it should have updated the form.
    Private Sub CallsignSearch_AfterUpdate()
    'if in list display all info on person


    'macro where ="[VolCallsign] = " & "'" & [Screen].[ActiveControl] & "'"
    'Dim dbrst As DAO.Database
    Dim rst As DAO.Recordset
    Dim strSearchCallsign As String

    'Set dbrst = CurrentDb
    'Set rst = dbrst.OpenRecordset("qryVolunteer")
    Set rst = Me.Recordset
    strSearchCallsign = "[VolCallsign] = '" & Me.CallsignSearch & "'" '[Screen].[ActiveControl]
    rst.FindFirst (strSearchCallsign)
    If rst.NoMatch Then
    MsgBox "Record not found"
    End If
    rst.Close
    Anyone see what I did wrong, this should have worked.

  2. #2
    Join Date
    Apr 2011
    Posts
    18
    If your form fields are showing #NAME? it sounds like whats listed in the forms recordsource, does not match whats listed in the controls controlsource.

    I would try to keep it simple, and not use a seperate DAO.Recordset, simply use the forms directly as shown below:
    Code:
    Dim strSearchCallsign As String
    strSearchCallsign = "[VolCallsign] = '" & Me.CallsignSearch & "'"
    Me.Recordset.FindFirst strSearchCallsign
    If Me.RecordSet.NoMatch Then
    MsgBox "Record not found"
    End If
    Remember that unless VolCallsign is a string type, then you should not use single quotes.

  3. #3
    k9drh is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Apr 2011
    Posts
    6
    Thanks for kicking brain cells lose. Yes I should have thought about using the form directly.
    again thanks for the help.

  4. #4
    Join Date
    Apr 2011
    Posts
    18
    You are most welcome!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Combo box with query and update
    By traction in forum Access
    Replies: 0
    Last Post: 11-24-2010, 02:38 PM
  2. Update form using combo box
    By rosh41 in forum Forms
    Replies: 1
    Last Post: 07-01-2010, 04:57 PM
  3. Combo box to update table in a form
    By TG_W in forum Programming
    Replies: 1
    Last Post: 05-20-2010, 01:59 PM
  4. Use combo box to update other fields
    By Shep in forum Access
    Replies: 7
    Last Post: 07-23-2009, 03:11 PM
  5. After Update for a second Combo box
    By nywi6100 in forum Forms
    Replies: 0
    Last Post: 10-23-2006, 03:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums