Buttons and forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

i have 2 buttons that take me to the same form, one is for viewing only and
the other editing.

when i click on the first button, i would only like to view records on the
form, so i would like to hide some editting buttons

but

when i click the second button i would like edit the records, so i would
like the buttons to reappear.

i have have other situations likes this but i think the coding will work on
most cases

can i do this

thank you
 
easiest way I can think to do that is copy and paste the form you open up and
change them to suit each button

or you could go something like this
openform "form",acpreview,,,acformreadonly

and see what that looks like
 
Hi, thanks for the response,

is there noway to set the button visible fiunction to equal NO and on the
other form to set the visible to YES

is this possible
 
hi,
yes it is possible.
the command is

commandbutton1.visible = true '(to show the button)
commandbutton1.visible = false '(to hide the button)

put the hide version in the view only button code to hide
the edit buttons on form open.
and i guess put the show version in the other button to
light the edit buttons up.
 
Hi,

thanks for the response, this goes to the form but comes up with a message
"Object Required"
the button is coded but i imagine all the buttons would be

can you help,

thanks again
 
Hello,

i have 2 buttons that take me to the same form, one is for viewing only and
the other editing.

when i click on the first button, i would only like to view records on the
form, so i would like to hide some editting buttons

but

when i click the second button i would like edit the records, so i would
like the buttons to reappear.

i have have other situations likes this but i think the coding will work on
most cases

can i do this

thank you

You can pass some OpenArgs text to the second form, and use that to
hide or show the different controls.

Form one command button:
DoCmd.OpenForm "FormName", , , , acFormReadOnly , , "Read Only"

From the other command button:
DoCmd.OpenForm "FormName", , , , acFormEdit , ,"Edit"

Code the second form's Load event:
If Me.OpenArgs = "Read Only" Then
Me!ControlA.Visible = True
Me!ControlB.Visible = True
Me!ControlC.Visible = False
Me!ControlD.Visible = False
ElseIf Me.OpenArgs = "Edit" Then
Me!ControlA.Visible = False
Me!ControlB.Visible = False
Me!ControlC.Visible = True
Me!ControlD.Visible = True
Else
' Some default here
End If
 
Hi,

below is the whole command that the hide command went in to :-

Private Sub cmdAllocationDetails_Click()
On Error GoTo Err_cmdAllocationDetails_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAllAllocation"
DoCmd.OpenForm stDocName, , , stLinkCriteria
cmdComplete.Visible = False
Exit_cmdAllocationDetails_Click:
Exit Sub

Err_cmdAllocationDetails_Click:
MsgBox Err.Description
Resume Exit_cmdAllocationDetails_Click

End Sub

hope this helps.
 
Back
Top