Set focus on a different Form

  • Thread starter Thread starter John
  • Start date Start date
J

John

I am sure this is easy to do but for the life of my I can't figure it out.
Any help for a self taught would be great

I currently have this on my customers form organized to e-mail someone that
the job is complete and the set the status as complete. Works fine...


Private Sub Command338_Click()
If IsNull([SignedOffDate]) Then
MsgBox ("Please enter in a signed off date")
Else

DoCmd.SendObject , acSendNoObject, , "e-mail address", , , "Customer
Complete " & [AssignedCustNumber] & " (" & [LastName] & ", " & [FirstName] &
")", [OwnerInfo] & Chr(13) & Chr(10) & "Therms Saved according to
multifamily= " & [Text404] & Chr(13) & Chr(10) & " " & Chr(13) & Chr(10) &
"John", True
[WrappedUpDate] = Date
[AcitivityStatus] = "Complete"
DoCmd.GoToControl ("Text136")
End If
End Sub

I have a button that pops up a options menu which is simply a form with
buttons on it. What I would like is a button on that form to do all of the
above code but I can't figure it out. This is what I have right now but it
doesn't work. Thanks in advance.

Private Sub Command29_Click()
DoCmd.Close
Me.frmcustomers.SetFocus
If IsNull([SignedOffDate]) Then
MsgBox ("Please enter in a signed off date")
Else

DoCmd.SendObject , acSendNoObject, , "EmailAddress", , , "Customer Complete
" & [AssignedCustNumber] & " (" & [LastName] & ", " & [FirstName] & ")",
[OwnerInfo] & Chr(13) & Chr(10) & "Therms Saved according to multifamily= " &
[Text404] & Chr(13) & Chr(10) & " " & Chr(13) & Chr(10) & "John", True
[WrappedUpDate] = Date
[AcitivityStatus] = "Complete"
DoCmd.GoToControl ("Text136")
End If
End Sub
 
Hi John,

you can refer to a control on another form as:
Forms("Name from")![ControlName]

If you do so, you better first check if the form is open. To do so I use
the following function:

Public Function gfgIsOpen(strName As String, Optional intObject As Integer =
acForm)


'Function to check whether an object is opened, when no object type is
'specified Access assumes a form

gfgIsOpen = (SysCmd(acSysCmdGetObjectState, intObject, strName) <> 0)


End Function
 
Back
Top