Access 2007. Disclaimer: I'm new at this.
I have frmCVBook based on tblCVBook both of which have 6 fields; 4 are visible in the form and 3 require user input for use later in a macro. There are no records yet. The dimmed variables strLOC, intREPS, and strREMARKS are assigned values via InputBox and used to fill fields in table record. The problem is that regardless of the order in which they are stated in the form code, the 3rd instance of the DoCmd.GoToControl, always generates the same error, that is: "RunTime Error '2046': The command or action 'GoToControl' isn't available now." I would appreciate anyone's help. Thanks! (similar to thread702-1455510?)
Here's entire Form code:
Option Compare Database
Option Explicit
Private Sub Form_Open(Cancel As Integer)
'Dim variables
Dim strLOC As String
Dim intREPS As Integer
Dim strREMARKS As String
'Collect data
DoCmd.GoToControl "LOC"
strLOC = InputBox("Trial Code(LL)?")
LOC = strLOC
DoCmd.GoToControl "REPS"
intREPS = InputBox("How many reps?")
REPS = intREPS
DoCmd.GoToControl "REMARKS"
strREMARKS = InputBox("Remarks?")
REMARKS = strREMARKS
DoCmd.Close (acForm)
End Sub
I have frmCVBook based on tblCVBook both of which have 6 fields; 4 are visible in the form and 3 require user input for use later in a macro. There are no records yet. The dimmed variables strLOC, intREPS, and strREMARKS are assigned values via InputBox and used to fill fields in table record. The problem is that regardless of the order in which they are stated in the form code, the 3rd instance of the DoCmd.GoToControl, always generates the same error, that is: "RunTime Error '2046': The command or action 'GoToControl' isn't available now." I would appreciate anyone's help. Thanks! (similar to thread702-1455510?)
Here's entire Form code:
Option Compare Database
Option Explicit
Private Sub Form_Open(Cancel As Integer)
'Dim variables
Dim strLOC As String
Dim intREPS As Integer
Dim strREMARKS As String
'Collect data
DoCmd.GoToControl "LOC"
strLOC = InputBox("Trial Code(LL)?")
LOC = strLOC
DoCmd.GoToControl "REPS"
intREPS = InputBox("How many reps?")
REPS = intREPS
DoCmd.GoToControl "REMARKS"
strREMARKS = InputBox("Remarks?")
REMARKS = strREMARKS
DoCmd.Close (acForm)
End Sub