Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2006

    Unanswered: Data type mismatch criteria errors

    Hi guys,

    Implementations application & programming environ
    MS Acess + Visual Basic

    Table fields
    Serialno (pk) - Auto number
    StudentId - text
    Course - text
    intake - number

    Combobox1 (StudentId) - predefined list
    TextBox1 (StudentId) - bound to controlsource StudentId
    TextBox2 (Course) - bound to controlsource course
    TextBox3(intake) userinput

    Private_Sub_Combo1_AfterUpdate event

    Dim rs as Object

    Set rs = Me.RecordSetClone
    rs.FindFirst "[Serialno] = " Str(Nz(Me![Combo1]))
    If Not rs.EOF Then Me.Bookmark = rs.Bookmark
    Me.StudentId.value = Combo1.Column(0)

    I am having an error (Data type mismatch criteria errors) on the last stat of the AfterUpdate event. I am aware that Str only take in Numerical values but nt too sure as hw that stat can be changed to take in string values.

    I have invoked the save command to add the below mentioned to Student table but i want to filter dupliacte student Id value selected from the combo box. I have set the field to Yes(No Duplicate) but getting an error this will allow duplicate value, refined index or remove duplicate in the fields. No idea as to what is it but i have provided the necessary info for review. Tks for assisting on this issue,

    Private Sub_Save event

    Dim rs as RecordSet
    Dim db as Database
    Set rs = Me.RecordsetClone
    Set db = CurrentDb
    Set rs = db.OpenRecordSet("Select StudentId, Course, intake from Student where StudentId = '" & Me.StudentId.value & "' And Course = ''" & Me.Course.value & "')
    If Not rs.EOF Then
    rs("StudentId").value = Combo1.value
    rs("Course").value = text2.value
    rs("intake").value = text3.value
    End If

    set rs = Nothing
    set db = Nothing


    Private Sub AddRecord event
    DoCmd.OpenForm "StudentRecord", acNormal, ,StudnetId = '" & Me.Combo1.Value & "' And course = '" & Me.textBox2.value & "'
    DoCmd, acAddForm
    DoCmd.GoToRecord , , acNewRec

  2. #2
    Join Date
    Jul 2003
    For the first problem...
    Why are you converting to a string? Just eliminate the STR() function, since
    SerialNO is a number
    Inspiration Through Fermentation

Posting Permissions

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