Hide cmdbutton when opening frm in add mode

mtagliaferri

Registered User.
Local time
Today, 20:02
Joined
Jul 16, 2006
Messages
550
I have this code to open a from in add mode to add a record, however I would like the edit cmd button to change to no visible when the form is open in add mode
Code:
Private Sub CmdAdd_Click()
DoCmd.OpenForm "frmAirport", acNormal, , , acFormAdd
Me.CmdEdit.Visible = False
End Sub
I have an error : Compile error Method or data member not found.
What code should I use?
 
I actually have a further issue....
the code
Private Sub CmdAdd_Click()
DoCmd.OpenForm "frmAirport", acNormal, , , acFormAdd
End Sub
works fine when it is opened from the form, however this form is inserted in a NavigationSubform and when opened via this form nothing works!!!
 
I have this code to open a from in add mode to add a record, however I would like the edit cmd button to change to no visible when the form is open in add mode
Code:
Private Sub CmdAdd_Click()
DoCmd.OpenForm "frmAirport", acNormal, , , acFormAdd
Me.CmdEdit.Visible = False
End Sub
I have an error : Compile error Method or data member not found.
What code should I use?

You have to refererence the control on the form you are opening :
Code:
 Forms!frmAirport.CmdEdit.Visible = False

Best,
Jiri
 
I have solved the issue of hiding the cmdEdi, however the cmdAdd does not work when the form is launched from the NavigationalForms.
Does this make sense?
 
I have solved the issue of hiding the cmdEdi, however the cmdAdd does not work when the form is launched from the NavigationalForms.
Does this make sense?

Again, I think this is a reference issue but I have a hard time visualizing what you are doing without cues. Maybe you can post a jpeg of the form and subform to start with.

Best,
Jiri
 
Here I am again....I have solved the issue for the cmdAdd as I have changed the code to
DoCmd.OpenForm "frmAirport", acNormal, "", "", acAdd, acDialog
and it opens the form correctly and adds the record.
However the code
Forms!frmAirport.CmdEdit.Visible = False
does no longer work and returns this error
Run-time error'2450': Microsoft Access cannot find the referenced 'frmAirport'.
Any ideas on why?
 
You can't open the Form in acDialog mode, remove that and it should go back to working.
 
Gina, why can't the form be opened in Dialog mode?

Of course, the code in the calling form is paused until the Dialog form is closed or hidden. Therefore the cmdEdit button will not be hidden until the Dialog form is closed.

Easiest is to move the hide button line to before the open form line.
 
Opening in Dialog makes the Form open *all by myself*, so the line to hide the button can't find it.
 
If I remove the remove the Dialog mode it wont open in add mode therefore I cannot add a record, this form is contained inside a navigational form
 
Hmm, are you saying you can't get to Add mode? There is something wrong there because you don't need Dialog to add a new record from a pop-up. What version of Access? And, what version is the file?
 
GinaWhipp I am on professional Plus 2010, what do you mean by file version?
 
.MDB or .ACCDB?

Just trying to confirm that you can do it in your present scenario because as I said, I have done it without Dialog Mode having to be set.
 
Okay, then it should work, so what happens that it won't open to add new when not in Dialog?
 
The command
Private Sub CmdAdd_Click()
DoCmd.OpenForm "frmAirport", acNormal, "", "", acAdd
Forms!frmAirport.CmdEdit.Visible = False
End Sub
works perfectly when it the form is opened separately (see Pic 1) it adds a records and the cmdButton Edit becomes NOT visible.
when I open the form Main (the final user uses) which is a navigational form where the form "frmAirport" resides nothing works (see Pic 2)
 

Attachments

  • Pic 1.jpg
    Pic 1.jpg
    75.7 KB · Views: 74
  • Pic 2.jpg
    Pic 2.jpg
    61.5 KB · Views: 79
Hmm, okay I see there were a few things left out... Continuous Form and Subform (or did I miss that?). No matter what those two separate or together are the issue.

Normally, when adding new you open a Form in Single view, allow the User to add then close that Form. Also, when you open a Form that is part of the Main Form it will take on the settings of the Main Form because as a Subform it is a Control.

My suggestion make a single Form for adding new.
 
I am confused, the form is a single form that opens on top of the main form as a separate form, I don't really understand where you coming from! :confused:
 
Okay, I misunderstood from your posted images...

So, back to the issue, please provide an image of what the Form looks like when you open without it being in Dialog Mode.
 

Users who are viewing this thread

Back
Top Bottom