combobox update?

eujeong

New member
Local time
Today, 05:51
Joined
Feb 5, 2014
Messages
6
HI, all.
I have problems in my form. Please advise for me.

I have a combobox which has 3 fields: StudentID(column 0), StudntName (column 1), StudentAddress (column 2).
When I put studnetID, if it is in the list then it's name and address fields are automatically filled (It works.). If the ID is not in the list, I want to get message box ( do you want to add the new ID on the list?) and add the ID on the student table.

I found this code:

Private Sub Combo292_NotInList(NewData As String, Response As Integer)

On Error GoTo myError

Dim rst As DAO.Recordset

Set rst = CurrentDb.OpenRecordset("Students", dbOpenDynaset)

If vbYes = MsgBox("This Entry is not in list. Do you wish to add " _
& NewData & " as a new StudnetID?", _
vbYesNoCancel + vbDefaultButton2, _
"New StudnetID") Then

rst.AddNew
rst!StudentID = NewData
rst.Update

Response = acDataErrAdded

Else

Response = acDataErrContinue

End If

leave:
If Not rst Is Nothing Then
rst.Close: Set rst = Nothing
End If

Exit Sub

myError:

MsgBox "Error " & Err.Number & ": " & Error$
Resume leave

End Sub

Problem 1: this code does not work. the new ID is added on the table, but the message box doesn't pop up when I put a new studentID.

Problem 2: although I would like to put each digit of studentID one by one when I put student ID, the first ID number abruptly pops up and if I want other number to put, I need to delete the first studentID. (i.e. if I want to put 0004, it automatically pops up 0001(the first ID) when I put first '0' on the box. then I should delete the '001' and then put '004'.)
Can I put the studentID one by one?

Please forgive my terrible english.:o

Can anybody help me out?
 
Hi EU,

First things first... Let's get the names of your fields straightened out. I see 'student', 'studnet' and 'studnt'. Now, these are all valid names, but they are confusing. Before investigating any further, I would go through and double check your field names and control names, just to make sure there aren't any typos. A typo would be the first thing to cause an error.

As for your problem #2, it looks like a "Search as You Type" scheme that is taking control of your filter. You could change that to an After Update function or even a Filter button to allow you to complete the StudentID before the search/filter occurs.

_________________
Regards,
Marvin M
Windows 7 Professional, MS Access 2007/2010
Windows 8 Professional, MS Access 2013
-------------------------------------------------------------------------------------------------------------------
If my post has helped you, please click the scales or click the 'Thumbs up'. Thanks!
-------------------------------------------------------------------------------------------------------------------
 
Thank you for your quick response.:)

problem 1 : I was hurry when I wrote my posting. All the name is starting with 'student'. I double checked my code again. Then what do need to do next?

problem 2 : could you give me any example of code for this function? I have no idea what I need to put in After Update function. Even I can't find the 'filter button'.

Thank you.
 

Users who are viewing this thread

Back
Top Bottom