setFocus ??

pdbowling

Registered User.
Local time
Today, 17:41
Joined
Feb 14, 2003
Messages
179
Hi all.

I've got a form...
I choose a selection from a combo box.

The selected record determines what needs to go in a text box and another combo.

I keep getting this error when I try to set focus on the textbox. How do I correct this?

"You must save the field before you execute the GoToControl action, the GoToControl Method, or the SetFocus method."

The code is as follows, 2 short functions.

Private Sub Combo0_BeforeUpdate(Cancel As Integer)
myType = Combo0.Text
myPos = InStr(1, myType, "F")
If myPos = 0 Then
myPos = InStr(1, myType, "T")
If myPos = 0 Then
MsgBox ("Not a Fork or Tugger in list")
Else
assignText ("T")
End If
Else
assignText ("F")
End If
End Sub

Sub assignText(myTruckType)
mySQL = "Select Distinct component from PCR where type like '" & myTruckType & "*'"
Combo2.RowSource = mySQL

Text8.Enabled = True
Text8.SetFocus <=== crashes here
Text8.Text = myTruckType
Combo2.SetFocus
Text8.Enabled = False
End Sub
 
Maybe...
Code:
DoCmd.RunCommand acCmdSaveRecord
 

Users who are viewing this thread

Back
Top Bottom