Results 1 to 6 of 6
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Combobox not 'connecting' (XP)

    I know that every hour of every day, somewhere on the planet, there's someone who's happily doing what I'm trying to do in Access, and they succeed without much thought to what they're doing. But it seems that every time I try to set up a record selector combo box on a form...well, here's the problem:

    I've built a form to find and edit the list of courses that a student has completed. The main form has text boxes to display the student's information (payroll ID, name and so on) and a subform to display the student's completed courses. I then added a record selector combobox in the main form header. I was careful to follow the advice I've gotten in this forum and in Helen Feddema's Access 2000 Inside Out . I've got the code in the VBA editor for the AfterUpdate event. However, I get "Error No. 3464...data type mismatch in criteria expression." I know I've overlooked something, but I'll be sheep-dipped if I can spot it. Where should I look?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combobox not 'connecting' (XP)

    If you create the record selector using the Combo Box Wizard, the wizard will take care of the gory details for you.

    The error you get probably means that you feed the routine a string while it expects a numeric ID or vice versa. Take a look at:
    <UL><LI>The row source of the combo box.
    <LI>The number of columns, the bound column and the column widths of the combo box.
    <LI>The AfterUpdate code.[/list]See if you can spot a string/numeric confusion. If not, post the information (row source etc.) here.

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: Combobox not 'connecting' (XP)

    G'morning, Hans! Thanks for that speedy reply. I was using the wizard, but I recall that something got sidetracked...don't remember exactly. I'll bet the root of the problem lies somewhere in that process. I think I'll start over with the ComboBox Wizard.

  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: Combobox not 'connecting' (XP)

    Hans: I still can't see the source of the "Data type mismatch in criteria expression." The field involved in the search is a number, not text. The combo box is unbound, of course, but it uses the very same record source as the main form, i.e., qryStudentLookup, which is based on tblStudents. I removed and reinserted the combo box with the Combo Box Wizard. I hesitate to post the DB--it's a bit big anyway, but I'll have to strip out some hard data before I can do that. Meanwhile, to answer your questions:

    Row source of the combo box = SELECT [qryStudentLookup].[PID] FROM [qryStudentLookup] That's precisely what the Combo Box Wizard put there--I had nothing to do with it directly. The qryStudentLookup uses tblStudents, and PID is the very first field in that table. PID is formatted as Number/Long Integer.

    The number of columns: just one, PID (payroll ID) .
    Bound column: 1 Column width: 0.6042"
    AfterUpdate code: Here goes:

    Private Sub cboSelectPID_AfterUpdate()

    On Error GoTo ErrorHandler

    Dim strSearch As String

    strSearch = "[PID] = " & Chr$(39) & _
    Me![cboSelectPID] & Chr$(39)

    ' Find the record that matches the control.
    Me.Requery
    Me.RecordsetClone.FindFirst strSearch
    Me.Bookmark = Me.RecordsetClone.Bookmark

    ErrorHandlerExit:
    Exit Sub

    ErrorHandler:
    MsgBox "Error No: " & Err.Number & "; Description: " & _
    Err.Description
    Resume ErrorHandlerExit

    End Sub

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Combobox not 'connecting' (XP)

    Hi Lucas,

    The code as it is now expects PID to be a string. To make it expect a number, just take out the Chr(39) (that is the code for a single quote):

    strSearch = "[PID] = " & Me![cboSelectPID]

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Virginia, USA
    Posts
    1,560
    Thanks
    37
    Thanked 1 Time in 1 Post

    Re: Combobox not 'connecting' (XP)

    Doh...! <img src=/S/doh.gif border=0 alt=doh width=15 height=15> Yeah, now it works! Thanks!

Posting Permissions

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