*Sigh* Looking for a solution to set defaultvalue and setfocus

G

Guest

Hello,

I have a bound form and two bound controls. Currently, in the beforeupdate()
event for control1, I am applying the uncommitted value as the defaultvalue
for itself, then undoing the record. I then want to set the focus to
control2. Unfortunately, I hit that darn error 2108 "You must save the field
before you can set focus... blah, blah" I understand why it's giving me the
error, but still, I'm looking for a solution.

What I'm trying to accomplish:
An employee scans (barcode) their EmployeeID, then they will scan a ticket
number. I have it programmed so that the program will "remember" their
Employee ID for a period of time, then reset it to null or the default. <--
This part works very well, but, when they scan in thier ID, I want the focus
to move to the second control. I don't want to save the record because the
second control is blank and their's nothing to record yet. Can anyone help
me? Thanks!!!
....I'm probably tired. I'm going home, maybe the answer will magically
appear tommorrow.

*snippet*
Private Sub txtEmployeeID_BeforeUpdate(Cancel As Integer)
If bolTimeOutIsPresent And (Not IsNull(txtEmployeeID)) Then
'change to new value
Me.txtEmployeeID.DefaultValue = txtEmployeeID
'reset counter
i = 0
Cancel = 1
Me.Undo
DoCmd.CancelEvent
Me.txtDTNumber.SetFocus
Else
'Me.Undo
'DoCmd.OpenForm "frmTryAgainDialog"
End If

End Sub
 
J

John Vinson

What I'm trying to accomplish:
An employee scans (barcode) their EmployeeID, then they will scan a ticket
number. I have it programmed so that the program will "remember" their
Employee ID for a period of time, then reset it to null or the default. <--
This part works very well, but, when they scan in thier ID, I want the focus
to move to the second control. I don't want to save the record because the
second control is blank and their's nothing to record yet. Can anyone help
me? Thanks!!!

I'm confused.

The *record* will not be saved just by scanning an ID. I think you can
use the AfterUpdate event of the EmployeeID textbox to set its own
Default property, and then setfocus to the other control; the record
does not need to be cancelled, or undone, as Access won't attempt to
write it to disk until you close the form or move off the record.

I think you've just made the problem harder than it really is! Am I
missing something?

John W. Vinson[MVP]
 
G

Guest

John,

I woke up this morning bright-eyed & bushy-tailed. I solved my own problem.
You were correct: "The *record* will not be saved just by scanning an ID"
(It would have in a previous version of the program.)
I was making it more difficult than it was. Sleep helps!

Thanks for your prompt reply, hope I didn't waste your time, I was
frustrated because this was the only thing that I needed to finish this
project.

Pat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top