Button Coding for Forms

C

channell

Ok, I posted a similar question, but I am not sure I explained myself enough
in order to get the correct answer. I have also lost the thread I was
working off of, and I aplologize to those who were helping me.

I have three forms I am working with. I have a main form with two subforms
in it. I have a combo box on the main form that will search through
employees and it pulls up all their records on the subforms. The two
subforms are based off the same information. Subform (a) is a more detailed
form with all the information I need. It is in "single form view". Subform
(b) is an abbreviated version of Subform (a) and is in "continuous forms
view". I want to place a button, or put code in one of the text boxes
(whichever is easier) on each record of subform (b) that when selected,
returns that matching fomr on subform (a).

Thank you very much in advance for any help that you assist me with. I
greatly appreciate it.
 
O

OssieMac

Hi Channell,

What about Double Click the field that has the data or Id required to find
the record for the other form and have a Double Click event. The following
does not use sub forms but you should get the idea of what you need to do.

I have a hidden textbox in the header of the continuous form called
CurrentEdit and the first thing the double click event does is make
CurrentEdit = the ProdId. ProdId has conditional formatting so that when
ProdId = CurrentEdit then the background is Yellow so that the user knows
where they are up to on the continous form.


Private Sub ProdId_DblClick(Cancel As Integer)

Dim tempProdId As Long

Me.CurrentEdit = Me.ProdId 'For Conditional format
Me.Recalc 'Forces update of conditional format

'Assign the ProdId to a temporary variable
tempProdId = Me.ProdId

'Open the required form. (If already open, does not matter.)
DoCmd.OpenForm "Product Details"

'Populate the field normally used to find record on the newly opened form.
Forms![Product Details].ProductNumber = tempProdId

'Set focus to newly opened form
Forms![Product Details].ProductNumber.SetFocus

'Call the event used in Product Details which is actually
'a find routine in newly opend Product Details form
Forms![Product Details].ProductNumber_AfterUpdate

End sub


The following formula is used in the conditional format
[ProdId]=[CurrentEdit]
 
C

channell

Thank you for the input. I will give it a shot, but I want you to know that
I am just barely learning visual basic coding, so I am almost clueless as to
how this works... I will let you know if it does or not. Thanks again.

OssieMac said:
Hi Channell,

What about Double Click the field that has the data or Id required to find
the record for the other form and have a Double Click event. The following
does not use sub forms but you should get the idea of what you need to do.

I have a hidden textbox in the header of the continuous form called
CurrentEdit and the first thing the double click event does is make
CurrentEdit = the ProdId. ProdId has conditional formatting so that when
ProdId = CurrentEdit then the background is Yellow so that the user knows
where they are up to on the continous form.


Private Sub ProdId_DblClick(Cancel As Integer)

Dim tempProdId As Long

Me.CurrentEdit = Me.ProdId 'For Conditional format
Me.Recalc 'Forces update of conditional format

'Assign the ProdId to a temporary variable
tempProdId = Me.ProdId

'Open the required form. (If already open, does not matter.)
DoCmd.OpenForm "Product Details"

'Populate the field normally used to find record on the newly opened form.
Forms![Product Details].ProductNumber = tempProdId

'Set focus to newly opened form
Forms![Product Details].ProductNumber.SetFocus

'Call the event used in Product Details which is actually
'a find routine in newly opend Product Details form
Forms![Product Details].ProductNumber_AfterUpdate

End sub


The following formula is used in the conditional format
[ProdId]=[CurrentEdit]


--
Regards,

OssieMac


channell said:
Ok, I posted a similar question, but I am not sure I explained myself enough
in order to get the correct answer. I have also lost the thread I was
working off of, and I aplologize to those who were helping me.

I have three forms I am working with. I have a main form with two subforms
in it. I have a combo box on the main form that will search through
employees and it pulls up all their records on the subforms. The two
subforms are based off the same information. Subform (a) is a more detailed
form with all the information I need. It is in "single form view". Subform
(b) is an abbreviated version of Subform (a) and is in "continuous forms
view". I want to place a button, or put code in one of the text boxes
(whichever is easier) on each record of subform (b) that when selected,
returns that matching fomr on subform (a).

Thank you very much in advance for any help that you assist me with. I
greatly appreciate it.
 
C

channell

Here's what I have so far and it works except for the fact that it is opening
the subform in a separate window. How do I make it just show up in the main
form view without another window opening up? This is linked to a button
which I would rather have. Thanks again!

Private Sub Command62_Click()
DoCmd.OpenForm "f6135MAINENTRYEASY", , , "[6135 ID] = " & Me.[6135 ID] &
""

End Sub







OssieMac said:
Hi Channell,

What about Double Click the field that has the data or Id required to find
the record for the other form and have a Double Click event. The following
does not use sub forms but you should get the idea of what you need to do.

I have a hidden textbox in the header of the continuous form called
CurrentEdit and the first thing the double click event does is make
CurrentEdit = the ProdId. ProdId has conditional formatting so that when
ProdId = CurrentEdit then the background is Yellow so that the user knows
where they are up to on the continous form.


Private Sub ProdId_DblClick(Cancel As Integer)

Dim tempProdId As Long

Me.CurrentEdit = Me.ProdId 'For Conditional format
Me.Recalc 'Forces update of conditional format

'Assign the ProdId to a temporary variable
tempProdId = Me.ProdId

'Open the required form. (If already open, does not matter.)
DoCmd.OpenForm "Product Details"

'Populate the field normally used to find record on the newly opened form.
Forms![Product Details].ProductNumber = tempProdId

'Set focus to newly opened form
Forms![Product Details].ProductNumber.SetFocus

'Call the event used in Product Details which is actually
'a find routine in newly opend Product Details form
Forms![Product Details].ProductNumber_AfterUpdate

End sub


The following formula is used in the conditional format
[ProdId]=[CurrentEdit]


--
Regards,

OssieMac


channell said:
Ok, I posted a similar question, but I am not sure I explained myself enough
in order to get the correct answer. I have also lost the thread I was
working off of, and I aplologize to those who were helping me.

I have three forms I am working with. I have a main form with two subforms
in it. I have a combo box on the main form that will search through
employees and it pulls up all their records on the subforms. The two
subforms are based off the same information. Subform (a) is a more detailed
form with all the information I need. It is in "single form view". Subform
(b) is an abbreviated version of Subform (a) and is in "continuous forms
view". I want to place a button, or put code in one of the text boxes
(whichever is easier) on each record of subform (b) that when selected,
returns that matching fomr on subform (a).

Thank you very much in advance for any help that you assist me with. I
greatly appreciate it.
 
M

Mike Painter

channell said:
Ok, I posted a similar question, but I am not sure I explained myself
enough in order to get the correct answer. I have also lost the
thread I was working off of, and I aplologize to those who were
helping me.

I have three forms I am working with. I have a main form with two
subforms in it. I have a combo box on the main form that will search
through employees and it pulls up all their records on the subforms.
The two subforms are based off the same information. Subform (a) is
a more detailed form with all the information I need. It is in
"single form view". Subform (b) is an abbreviated version of Subform
(a) and is in "continuous forms view". I want to place a button, or
put code in one of the text boxes (whichever is easier) on each
record of subform (b) that when selected, returns that matching fomr
on subform (a).

Thank you very much in advance for any help that you assist me with.
I greatly appreciate it.

The single record subform should be based on the same query as the multiple
record one with one exception.
The criteria would include the record ID of the form highlighed.
No buttons are needed.

I'm sure there are samples on the web. (related or nested subforms)
If not buy, a copy of the Access Developer's hand book, the code is there.
Buy it anyway
 
O

OssieMac

I am not full bottle on sub forms so perhaps Mike's suggestion is the best
answer.

--
Regards,

OssieMac


channell said:
Here's what I have so far and it works except for the fact that it is opening
the subform in a separate window. How do I make it just show up in the main
form view without another window opening up? This is linked to a button
which I would rather have. Thanks again!

Private Sub Command62_Click()
DoCmd.OpenForm "f6135MAINENTRYEASY", , , "[6135 ID] = " & Me.[6135 ID] &
""

End Sub







OssieMac said:
Hi Channell,

What about Double Click the field that has the data or Id required to find
the record for the other form and have a Double Click event. The following
does not use sub forms but you should get the idea of what you need to do.

I have a hidden textbox in the header of the continuous form called
CurrentEdit and the first thing the double click event does is make
CurrentEdit = the ProdId. ProdId has conditional formatting so that when
ProdId = CurrentEdit then the background is Yellow so that the user knows
where they are up to on the continous form.


Private Sub ProdId_DblClick(Cancel As Integer)

Dim tempProdId As Long

Me.CurrentEdit = Me.ProdId 'For Conditional format
Me.Recalc 'Forces update of conditional format

'Assign the ProdId to a temporary variable
tempProdId = Me.ProdId

'Open the required form. (If already open, does not matter.)
DoCmd.OpenForm "Product Details"

'Populate the field normally used to find record on the newly opened form.
Forms![Product Details].ProductNumber = tempProdId

'Set focus to newly opened form
Forms![Product Details].ProductNumber.SetFocus

'Call the event used in Product Details which is actually
'a find routine in newly opend Product Details form
Forms![Product Details].ProductNumber_AfterUpdate

End sub


The following formula is used in the conditional format
[ProdId]=[CurrentEdit]


--
Regards,

OssieMac


channell said:
Ok, I posted a similar question, but I am not sure I explained myself enough
in order to get the correct answer. I have also lost the thread I was
working off of, and I aplologize to those who were helping me.

I have three forms I am working with. I have a main form with two subforms
in it. I have a combo box on the main form that will search through
employees and it pulls up all their records on the subforms. The two
subforms are based off the same information. Subform (a) is a more detailed
form with all the information I need. It is in "single form view". Subform
(b) is an abbreviated version of Subform (a) and is in "continuous forms
view". I want to place a button, or put code in one of the text boxes
(whichever is easier) on each record of subform (b) that when selected,
returns that matching fomr on subform (a).

Thank you very much in advance for any help that you assist me with. I
greatly appreciate it.
 

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