Solved If form is opened acFormAdd then make controls visible or not

Zydeceltico

Registered User.
Local time
Today, 17:15
Joined
Dec 5, 2017
Messages
843
Hi All -

I have a form, frmJobDetails, where (drum roll please) details of a job are stored, added, reviewed, etc.

In other words, the form has many purposes.

This form gets called from a variety of other forms: it can be called from the main menu for reviewing job details. It can also be called from the Main Menu with a different button control to add a new job. It can also be called from an inspection form to add a new job.

When reviewing job details as opposed to adding a new job, I would like to make the "Save New Job" button invisible or at least dimmed as inactive.
Conversely, I would also like to know how to make those same buttons active and visible when opening the form as "acFormAdd" as in this code:
Code:
Private Sub cmdSave_Click()
Dim strOpenArg As String
    strOpenArg = Me.txtJobNumber & "|" & Me.txtTask & "|" & Me.txtResource
    DoCmd.Close
    DoCmd.OpenForm "frmJobDetails", acNormal, , , acFormAdd, acNormal, strOpenArg
End Sub

Is there a way to check how a form is opened and then turn controls "on" and "off" depending on the condition?

Guidance and insight - as always - is greatly appreciated.

Thanks,

Tim
 
I should likely clarify that the code above is my current workaround for adding a new job from a button on the main form ("Add New Job") which opens a new record in tblJobs and records data for our 3-part job numbers as a new record and then opens frmJobDetails to complete describing the other details of the new job.
 
If you are able to go from a new record to a new record then use the on current event. You can also set up a "toggle" instead of using a longer if then checks
me.someControl.visible = not me.NewRecord

The above will hide a control if new record and then show it if not a new record. Because if it is a new record the right side returns false, and the control is hidden. If not a new record then
not (me.newRecord) = not (false) = true
 
If you are able to go from a new record to a new record then use the on current event. You can also set up a "toggle" instead of using a longer if then checks
me.someControl.visible = not me.NewRecord

The above will hide a control if new record and then show it if not a new record. Because if it is a new record the right side returns false, and the control is hidden. If not a new record then
not (me.newRecord) = not (false) = true
Thanks! That's got it.
 

Users who are viewing this thread

Back
Top Bottom