473,765 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Data type mismatch criteria errors

46 New Member
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
2 2590
NeoPa
32,572 Recognized Expert Moderator MVP
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
technocraze
46 New Member
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

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

Similar topics

3
3977
by: Laurel | last post by:
this is driving me crazy. i need to use a form control as a criteria in a select query, and the control's value is set depending upon what a user selects in an option group on the form. the query results should return information on either a single employee or all employees. the problem that i have is that if i type in "*" (but without quotes) in the QBE criteria, it works fine. however, if i use Iif() to determine whether or not there...
3
3583
by: Martin Lacoste | last post by:
Is there some issue with using too many left/right/mid/len functions in queries? Depending on the usage, they work fine, but... then there's here: SELECT Master_CAO.Incipit, Master_CAO.FullText, Len() AS , Left(!,Len()) AS FROM Master_CAO WHERE (((Left(,Len()))<>));
0
2254
by: news.paradise.net.nz | last post by:
I have been developing access databases for over 5 years. I have a large database and I have struck this problem with it before but can find nothing in help or online. Access 2000 I have a query that will run fine without any criteria but as soon as I add any criteria it gives a "Data type mismatch" error. As soon as I remove any criteria it runs perfectly. I know this query is based on another query but I have other processes based on...
1
3281
by: amitbadgi | last post by:
I am getting the following error while converting an asp application to asp.net Exception Details: System.Runtime.InteropServices.COMException: Data type mismatch in criteria expression. Source Error: Line 233: Line 234: rs =
4
35490
by: bleighfield | last post by:
Hi everyone Hope someone can help with this one.. Background: I work in vehicle fleet, I have built something to 'predict' when a car/van service is due (it's fairly simple, calculates miles per day between 2 known dates/mileages and then uses the service schedule to work out what date the next service would be due, selecting the 'closer'
2
9004
by: psychomad | last post by:
Please, can someone help me out to solve this error, i've been searching throughout my codes and yet i didnt succeed in finding the error!!!! The Error is: Server Error in '/' Application. -------------------------------------------------------------------------------- Data type mismatch in criteria expression.
19
21570
by: Lysander | last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the date is more than 10 months out. The query runs fine, but I when I put the criteria of >10 I get 'Data Type mismatch' error. The code below is the original query. I have since put all the datediff bit in code, with all variables declared as date,...
6
2185
by: samuel84 | last post by:
Hi, I am getting the error "invalid use of null" when summing value from a range which has no value and "data type mismatch in criteria expression" when there are values to be summed up. Is there an error in my code? could someone please point out the error and why am I gettin these errors. Private Sub cmdCalculate_Click() Dim uDT1 As String Dim uDT2 As String Dim uGT As Double
9
4089
by: nixonmg | last post by:
When the Command Button "Notify" is clicked, I am wanting to send out an email to the user with appropriate information in the email (works great), check the "Notified" check box (does not work), and disable the "Notify" button (works). After the email is sent off, i get a Data type mismatch in criteria expression error. I am completely stumped. Any help would be greatly appreciated! Here is my code (I removed the email portion as it is...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.