getting a strange error 2108

gillbates21

Registered User.
Local time
Today, 17:14
Joined
Apr 8, 2006
Messages
15
I have the following code:


Code:
Private Sub cboUsername_BeforeUpdate(Cancel As Integer)
    
    cboULevel.SetFocus
    cboULevel.Value = DLookup("ULevel", "tbl_users", "[UID]=" & Me.cboUsername.Value)
    
End Sub

Getting the strange error 2108 (save the field before using SetFocus)

The error is on the cboULevel.SetFocus line.
The cboUsername combo gets its values form rowsource:
SELECT [tbl_users].[UID], [tbl_users].[Username] FROM tbl_users;
(it displays the values it should just fine)

I also tried the cboUsername_Change sub, but then nothing happens.

Any ideas or has someone accountered smt like this?
 
Last edited:
It is because you are in the middle of updating cboUserName and you are trying to set focus to a different combo box. Can you use the After Update Event? This will probably not produce the error.
 
You don't need to set focus to that control to set its value. You can eliminate that line.
 
lol, thanks, that select line was indeed not necessary.

EDIT: And in another situation the afterupdate event was the right one to use. Thanks KeithG

But can anybody say, why can't I declare this:
Dim db As Database ???

Also no additem property for a combobox :confused:

and for example
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("SELECT Username FROM tbl_users")

this result an error 13, type mismatch
 
Last edited:

Users who are viewing this thread

Back
Top Bottom