Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Actions between pop up and main forms

Status
Not open for further replies.

azalealee

Programmer
Nov 21, 2002
36
0
0
AU
Hi there! I have a continuous form that lists work orders (F_List_WOs). This form has an option group (opStatus) for each work order record with three choices, Complete, Incomplete or Not Required. When the user selects Not Required, a pop-up form (PUF_Incomplete) opens with three command buttons. There are a couple of things I'm having trouble with.

Firstly, I would like to have the option group in F_List_WOs to automatically select the Incomplete option if the user hits "Cancel" on PUF_Incomplete. I'm not quite sure how to set this to my main form for the correct Work Order.

Secondly, if the user hits the button "Create a new Unscheduled Work" on PUF_Incomplete, I would like to open up another form (F_Unsched_Work), passing all the required fields from the current record in F_List_WOs. Again, I'm not sure how I would get the correct fields from F_List_WOs and pass them to a new record in F_Unsched_Work.

Hope I've made some sense. Thanks in advance.

Azalea.
 
1. On your Cancel event, add the following code to enter “incomplete” as a chosen option for F_List_Wos.

Me.OptionGroupName = “Incomplete”

2. I assume your F_Unsched_Work shares the same table with PUF_incomplete, each record has a primary key (unique ID). So when you hit the button “create a new unscheduled work”, you basically open another form contains the same info of this record, but a few additional fields to schedule the work. If that is the case, here is the codes you need to call up the same record on F_Unsched_Work

On Error GoTo 0
Dim DocName As String
Dim LinkCriteria As String

DocName = " F_Unsched_Work"
LinkCriteria = "[PrimaryKeyName]='" & [Forms]![ PUF_Incomplete]![PrimaryKeyFieldName] & " ' "
DoCmd.OpenForm DocName, , , LinkCriteria, acNormal

This should work! happy learning!
 
Thanks for your suggestions HomeAlone.

1)I tried to use Me.opStatus = "incomplete" on the cancel button for PUF_Incomplete, but the option group is in F_List_WOs - not the pop up.

2)I should have mentioned that PUF_Incomplete is an unbound form, but I'll try your suggestion by passing the key field
to PUF_Incomplete to open F_Unsched_Work.

Azalea
 
1). declare a public dimension in the Module (Name whatever module you want) this module just create a container to store and indicate someone has just click the cancel button on PUF_Incomplete. It has to be declared in module to allow global access by other forms

Option Compare Database 'Given
Option Explicit 'Given
Public CancelIncomplete As Boolean 'I called it "CancelIncomplete"

On your Cancel button On_Click event, code this to indicate someone has clicked the Cancel button

CancelIncomplete = False
(I hope you have other codes here to close this form and open the other form)

Finally, code the following codes On_pen event of the form F_List_Wos to plug in the "Incomplete"

If CancelIncomplete = False Then
Me.opStatus = "incomplete"
CancelIncomplete = True 'reset to true
Else
Exit Sub
End If

2. As long you can provide the record ID on the PUF_Incomplete form, it doesn't matter if it is an unbound form. The codes should be able to pull the record for you.
 
I created the module, threw in the bit of code on the On Click event of the cancel button, but I added Me. Requery into the code for the Form_Activate event.

Ie:If CancelIncomplete = False Then
Me.opStatus = "incomplete"
CancelIncomplete = True 'reset to true
Me.Requery
Else
Exit Sub
End If

This is because the form doesn't actually close, but just sits behind the pop-up.

I don't know why, but the re-query doesn't seem to work. It's only when I close the form and open it back up that Incomplete is selected.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top