Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2006
    Posts
    40

    Unanswered: type mismatch issue

    Hi community experts,

    Environment: MS Acess with visual basic

    Another issue I am encountering is the error meesage: Type mismatch. This occured at the Combo_After Update event.

    To make it simple i am trying to display the corresponding values (StudentId, Name) into the textboxes from registration table. The values from the combo box is from a query. (Select distinct StudentId from Registration order by StudentId).

    It mean that when I select the value from the combo box, the corresponding values matching that studentid will be displayed and i only want the studentid and name to be displayed in the bounded textboxes.

    I will provide detailed information with explicit explanation so that the experts can look into the issues without much difficiluty and also prevent any misleading of information.

    Design View

    StudentId - unbounded combo box
    Student - bounded textbox
    Name - bounded textbox
    subject - unbounded textbox
    course - unbounded textbox

    Table view

    Registration
    Serialcode - primary key (Autonumber)
    StudentId - text
    Name - text
    course - text
    subject -text

    Query (sql view)
    Select distinct StudentId from Registration

    Code

    Private Sub Combo1 AfterUpdate()
    Dim rs as DAO.Recordset
    set rs = Me.RecordSetClone
    rs.FindFirst "[Serialcode] = " Str(Nz(Me![Combo1])) - Error
    If not rs.EOF then Me.Bookmaek = rs.Bookmark

    Message error: Type mismatch

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    You are searching a number field with string data.
    Do away with the STR function.
    Inspiration Through Fermentation

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    There's also no point in using the nz() function without two arguments. You've got that where clause wrapped up in a bunch of functions that have no business being there. What is it you're trying to do?

    Edit: Also, you're not concatenating strings together for your where clause.

    I'm going to take a wild guess and say you want:

    rs.FindFirst "[Serialcode] = " & Me![Combo1]
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  4. #4
    Join Date
    Nov 2006
    Posts
    40
    Correction
    Private Sub Combo1_AfterUpdate()

    ' Find the record that matches the control.
    Dim rs As DAO.Recordset
    Set rs = Me.Recordset.Clone
    rs.FindFirst "[Serialno] = " & Str(Nz(Me![Combo66], 0))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark

    End Sub

    The same error with suggested solutions - type mismatch

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    That's not what I posted.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

Posting Permissions

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