Change backcolor of Form from a cmdbutton

S

stumpy

I have a form which can be opened using different cmd buttons in different
locations
Is it possible to change the backcolor of the form being opened depending on
which button is used.

stdocname = "MEETING DETAILS"
DoCmd,OpenForm stdocName,,,stLinkCriteria
DoCmd.GoToRecord,,acNewRecord

Is it possible to set the backcolor of form "MEETING DETAILS" at this stage

any help would be appreciated
 
L

Linq Adams via AccessMonster.com

Sure, just use OpenArgs when opening the forms.

In your calling form:
DoCmd,OpenForm stdocName, , ,stLinkCriteria, , , "CallingFormA"


In the form to be opened:

Private Sub Form_Load()
If Len(Nz(Me.OpenArgs, "")) > 0 Then

If Me.OpenArgs = "CallingFormA" Then
'Place your formatting code for when FormA calls
End If

If Me.OpenArgs = "CallingFormB" Then
'Place your formatting code for when FormB calls
End If

If Me.OpenArgs = "CallingFormC" Then
'Place your formatting code for when FormC calls
End If

End If

End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
A

Arvin Meyer [MVP]

It looks as if you only want to change the color of a new record. So just
add the line:

Me.Section(0).Backcolor. = vbWhite ' or any other color

Once you do that, though, the back color of the form will stay that way as
long as the form is open. You may want to reset it in the Form's Current
event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top