Data type mismatch criteria errors

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • technocraze
    New Member
    • Jan 2007
    • 46

    #1

    Data type mismatch criteria errors

    Hi guys,

    Implementations application & programming environ
    MS Acess + Visual Basic

    Code:
    Table fields
    Serialno (pk) - Auto number
    StudentId - text
    Course - text
    intake - number
    Code:
    Control 
    Combobox1 (StudentId) - predefined list 
    TextBox1 (StudentId) - bound to controlsource StudentId
    TextBox2 (Course) - bound to controlsource course
    TextBox3(intake) userinput
    Code:
    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,

    Code:
    Private Sub_Save event
    On_Error.......
    
    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.MoveNext
    rs.AddNew
    rs("StudentId").value = Combo1.value
    rs("Course").value = text2.value
    rs("intake").value = text3.value
    rs.update
    rs.close
    End If
    
    set rs = Nothing
    set db = Nothing
    OR

    Code:
    Private Sub AddRecord event
    DoCmd.OpenForm "StudentRecord", acNormal, ,StudnetId = '" & Me.Combo1.Value & "' And course = '" & Me.textBox2.value & "'
    DoCmd, acAddForm
    DoCmd.GoToRecord , , acNewRec
    Last edited by NeoPa; Jan 16 '07, 12:59 AM. Reason: Tags
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    I can see you've made a great effort to post as well as you can here with many of the suggestions followed from the guidelines. Unfortunately, what I can see of your code and setup is so unlike how to do things in Access I'm confused as to where to start. Have you looked at any of the tutorials linked to from this site? Not just the ones on here but other sites too. It seems harsh but I think you need to look at some examples of things similar to what you want then change them for your purposes. I didn't want to post this and just criticise, but I wouldn't be happy to leave you still working that way. Do you have any support at work? Someone who can help guide you in the right direction.
    For your specific question about the Data type mismatch, I think you need to look at the ComboBox value in the first column.
    StudentID is text (according to your post) so should take any value. Even this doesn't make sense. The code looks as if it couldn't possibly run so I don't understand how it can give an error. I'm too confused to be of any more help. Sorry.

    Comment

    • technocraze
      New Member
      • Jan 2007
      • 46

      #3
      Thanks pals for yr kind advice. I have manage to resolve my issue.

      Originally posted by NeoPa
      I can see you've made a great effort to post as well as you can here with many of the suggestions followed from the guidelines. Unfortunately, what I can see of your code and setup is so unlike how to do things in Access I'm confused as to where to start. Have you looked at any of the tutorials linked to from this site? Not just the ones on here but other sites too. It seems harsh but I think you need to look at some examples of things similar to what you want then change them for your purposes. I didn't want to post this and just criticise, but I wouldn't be happy to leave you still working that way. Do you have any support at work? Someone who can help guide you in the right direction.
      For your specific question about the Data type mismatch, I think you need to look at the ComboBox value in the first column.
      StudentID is text (according to your post) so should take any value. Even this doesn't make sense. The code looks as if it couldn't possibly run so I don't understand how it can give an error. I'm too confused to be of any more help. Sorry.

      Comment

      Working...