PDA

View Full Version : type mismatch error



technocraze
01-30-2007, 09:27 AM
Hi OBP & community experts,

Another issue I am encountering is the error : Type mismatch error message. 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.Recordsetset rs = Me.RecordSetClone
rs.FindFirst "[Serialcode] = " Str(Nz(Me![Combo1],0)) - Error
If not rs.EOF then Me.Bookmaek = rs.Bookmark

Message error: Type mismatch

ElvisFan
01-30-2007, 02:21 PM
Hello, this may seem kind of basic. I am not very good at this but, check to make sure that StudentID records from Registration are all the same type of data. Text for example. Also, if the combo box is looking for integers and the StudentID is text, that could cause the problem you are talking about. Like I said, I am not a very good programmer but sometimes I can come up with solutions.

OBP
01-31-2007, 06:57 AM
I agree with ElvisFan's advise.

alimcpill
01-31-2007, 08:38 AM
But if you are trying to filter for studentid, why is the rs.FindFirst line looking for SerialCode? You are calling Str() on the value of Combo1, which according to your example is populated by StudentId, which is a text field. Calling Str() on a non-numeric string will give you a type mismatch.

Or have I misunderstood something...

moa
01-31-2007, 09:47 AM
rs.FindFirst "[Serialcode] = " & Str(Nz(Me![Combo1],0))

No idea if this is the problem but it just looked wrong...