Results 1 to 7 of 7
  1. #1
    vad77 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Location
    USA
    Posts
    105

    Error on Form with combo box control


    I have 3 forms built using 3 different queries as the data source. One query shows my active records, one shows my alarm records and one shows all records. The reason for the 3 different forms and queries is that each form need to show different fields. I have a combo box on each form to goes to the selected record from the combo box. The problem is with the form that shows my active records. When I first load the database and select an item from the combo box I get an error "Return without GoSub". When I click OK then I get the macro error.
    Click image for larger version. 

Name:	accesserror2.JPG 
Views:	23 
Size:	31.3 KB 
ID:	15159

    I find when I go into design view and click on the event procedure and then just exit without doing anything the combo box will start to work.
    When I exit the database and start it again is when the combo box stops working again. I never ran into this kind of problem before and really don't know how to correct the issue.
    Thanks in advance for your repsonses!

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Are you using code in the afterupdate or another event handler for your combo? Did you embed a macro in the event properties for the combo? Maybe you can post a screenshot of the Property Sheet for your combo that is throwing the exception. Make sure the Event Tab on the property sheet is selected.

  3. #3
    vad77 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Location
    USA
    Posts
    105
    Thanks for your response, I used the combo box wizard to build the combo box. Here are the screen shots of the event property and the embedded macro.
    The other odd thing is that I can tell that there is a problem when I open the form. I have two fields that have conditional formatting and my first record meets the criteria but the fields do not show the conditional format. The other is a control box with an expression to calculate the date diff beween a date field and the current date. When the form is open that control box shows #Name? instead of the result. Once I correct the combo box all those other items work.

    Click image for larger version. 

Name:	accesserror3.JPG 
Views:	21 
Size:	46.1 KB 
ID:	15161Click image for larger version. 

Name:	accesserror4.JPG 
Views:	21 
Size:	58.6 KB 
ID:	15162

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    How about getting rid of the macro and using some VBA in the after update event? Looking at the maceo it should work but the Argument is a little on the odd side.

    To not have the combo associated with the macro you can erase the text "[Embedded Macro]" from the After Update field. Then you can create an event handler by clicking the elipses (...) and selecting "Code Builder" from the option provided. Now you will need to place some VBA in the event handler you just created. You will have to change the text in red to match your combo name and I am assuming the first column in your combo has a text field and this is the field with cust_name.

    Code:
    Dim rs As DAO.Recordset
    If Not IsNull(Me.ComboboxName) Then
        If Me.Dirty Then
            Me.Dirty = False
        End If
        Set rs = Me.RecordsetClone
        rs.FindFirst "[cust_name] = '" & Me.ComboboxName.Column(0) & "'"
        If rs.NoMatch Then
            MsgBox ("Not found")
        Else
              If rs.Bookmarkable = False Then
              MsgBox "Can't bookmark this record"
              Else
              Me.Bookmark = rs.Bookmark
              End If
        End If
        Set rs = Nothing
    End If

    edit:

    Also understand that this code is saving your current record. May not work or may not be what you want in your case.

    Code:
        If Me.Dirty Then
            Me.Dirty = False
        End If

  5. #5
    vad77 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Location
    USA
    Posts
    105
    Thanks again @ItsMe I will try the code you provided. As I get better with code I stay away from macros and this forum has been a big help in finding the code I need. The purpose of this combo box is basiclly to go to a specific record when I need information from that record. This report which has just become my responibilty was in an Excel spreadsheet and yesterday I had the first meeting with the directors to review the spreadsheet. As I imagined it was a pain scrolling back nad forth in the spreadsheet to see the information they wanted to see. I hope to roll this out to them in the future once I work out the kinks and add the filters I need now knowing how they review the report.
    I will let you know how it turns out.
    Thanks again!!!

  6. #6
    vad77 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Dec 2013
    Location
    USA
    Posts
    105
    It works perfectly!! Thanks again. I created the code then saved and closed and opend the database and I did not get the error. I am going to change the combo boxes on my other forms even though I don't have the problem with those forms.

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Good to hear. I am not sure what the original problem was but using code like the example above can be helpful if something goes wrong. You can debug the code but breaking down where a macro fails can be difficult.

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

Similar Threads

  1. Circluar SQL Error in Form Control
    By Monterey_Manzer in forum Forms
    Replies: 13
    Last Post: 01-09-2013, 07:23 PM
  2. Replies: 2
    Last Post: 04-17-2012, 12:56 PM
  3. #Type! error in form control
    By Ashe in forum Forms
    Replies: 2
    Last Post: 09-29-2011, 12:44 PM
  4. Form Control Button / Combo Box
    By canuck in forum Forms
    Replies: 1
    Last Post: 03-18-2011, 10:17 AM
  5. Replies: 5
    Last Post: 09-06-2010, 11:50 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