PDA

Click to See Complete Forum and Search --> : command button problem...


softwareguy74
Aug 24th, 2000, 04:32 PM
I have a form with a text field on it that's bound to a database
at run time with the following code:

Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "select * from tblPreferences", db, adOpenStatic, adLockOptimistic

'connect text boxes to database
For Each oText In Me.txtFields
Set oText.DataSource = adoPrimaryRS
Next

I then have a command button named cmdOk on my form with the following code:

msgbox "test..."
adoPrimaryRS.Update
Unload Me

When actually clicking on cmdOk, all 3 lines of code execute as they should. In other words,
the msgbox pops up, any changes made in the text box is saved to the database and the form closes.

But for some strange reason, when I set cmdOk.Default = True and then just hit the enter key, only line 1 and 3 execute, but not line 2.

This also holds true for cmdOk.Cancel = True and just hitting the escape key.

Why is adoPrimaryRS.Update not executing when hitting the esc key or the enter button but executing when I actually click on the button?

Any help would be appreciated..

Dan