fat controller
Slightly round the bend..
- Local time
- Today, 16:29
- Joined
- Apr 14, 2011
- Messages
- 758
I have code that works when parts of it are executed separately, but put together it either partly works or does not work at all. I have tried a couple of variations with little luck.
Variation 1
Variation 2
Essentially, what I am trying to achieve is:

Variation 1
Code:
If Me.tckRtn10 = True Then
If Me.txtRtnRef.Value = Null Then
Dim strFrmName As String
strFrmName = "Form2"
DoCmd.OpenForm strFrmName, acNormal
With Forms(strFrmName)
.txtEmployee_Number = Me.txtEmployee_Number
.txtInitials = Me.txtInitials
End With
Else
Dim varInput
varInput = [Forms]![Form1]![txtRtnRef]
DoCmd.OpenForm "Form2", acNormal
Me.Our_Order_Number.SetFocus
DoCmd.FindRecord varInput, acEntire, , acSearchAll, False, acCurrent
End If
End If
End Sub
Variation 2
Code:
If Me.txtRtnRef.Value = Null Then
If Me.tckRtn1 = True Then
Dim strFrmName As String
strFrmName = "Form2"
DoCmd.OpenForm strFrmName, acNormal
With Forms(strFrmName)
.txtEmployee_Number = Me.txtEmployee_Number
.txtInitials = Me.txtInitials
End With
End If
End If
If Not IsNull(txtRtnRef) Then
If Me.tckRtn1.Value = True Then
Dim varInput
varInput = [Forms]![Form1]![txtRtnRef]
DoCmd.OpenForm "Form2", acNormal
Me.Our_Order_Number.SetFocus
DoCmd.FindRecord varInput, acEntire, , acSearchAll, False, acCurrent
End If
End If
Essentially, what I am trying to achieve is:
- When checkbox is ticked, and there is nothing in the textbox txtRtnRef, I want Form2 to open and the values from txtEmployee_Number and txtInitials passed over (this works on its own)
- When checkbox is ticked, and there is a value in the textbox txtRtnRef, I want Form2 to open, the control Our_Order_Number to get focus, and then find record(s) that match the text contained in txtRtnRef on Form1 (this also works on its own)
- If the checkbox is unticked, I don't want anything to happen.