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
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