By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,209 Members | 1,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,209 IT Pros & Developers. It's quick & easy.

Data type mismatch criteria errors

P: 46
Hi guys,

Implementations application & programming environ
MS Acess + Visual Basic

Expand|Select|Wrap|Line Numbers
  1. Table fields
  2. Serialno (pk) - Auto number
  3. StudentId - text
  4. Course - text
  5. intake - number
Expand|Select|Wrap|Line Numbers
  1. Control 
  2. Combobox1 (StudentId) - predefined list 
  3. TextBox1 (StudentId) - bound to controlsource StudentId
  4. TextBox2 (Course) - bound to controlsource course
  5. TextBox3(intake) userinput
Expand|Select|Wrap|Line Numbers
  1. Private_Sub_Combo1_AfterUpdate event
  2.  
  3. Dim rs as Object
  4.  
  5. Set rs = Me.RecordSetClone
  6. rs.FindFirst "[Serialno] = " Str(Nz(Me![Combo1]))
  7. If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  8. 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,

Expand|Select|Wrap|Line Numbers
  1. Private Sub_Save event
  2. On_Error.......
  3.  
  4. Dim rs as RecordSet
  5. Dim db as Database
  6. Set rs = Me.RecordsetClone
  7. Set db = CurrentDb
  8. Set rs = db.OpenRecordSet("Select StudentId, Course, intake from Student where StudentId = '" & Me.StudentId.value & "' And Course = ''" & Me.Course.value & "')
  9. If Not rs.EOF Then
  10. rs.MoveNext
  11. rs.AddNew
  12. rs("StudentId").value = Combo1.value
  13. rs("Course").value = text2.value
  14. rs("intake").value = text3.value
  15. rs.update
  16. rs.close
  17. End If
  18.  
  19. set rs = Nothing
  20. set db = Nothing
OR

Expand|Select|Wrap|Line Numbers
  1. Private Sub AddRecord event
  2. DoCmd.OpenForm "StudentRecord", acNormal, ,StudnetId = '" & Me.Combo1.Value & "' And course = '" & Me.textBox2.value & "'
  3. DoCmd, acAddForm
  4. DoCmd.GoToRecord , , acNewRec
Jan 15 '07 #1
Share this Question
Share on Google+
2 Replies


NeoPa
Expert Mod 15k+
P: 31,494
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.
Jan 16 '07 #2

P: 46
Thanks pals for yr kind advice. I have manage to resolve my issue.

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.
Jan 16 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.