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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pass selection from pop-up form to main form & populate field

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Good day to you all,

I am using Access 2003 with VBA and need help passing user selected information from pop-up forms to a main form and placing it in particular fields in the main form. I have three pop-up forms. The first contains an option group (with option buttons), a second one contains a combo list box, and a third contains a text box (the boss wants it this way). The pop-up and model properties for the pop-up forms are set to Yes. I hope that if we get one working, I can modify the code for the other two.

Each pop-up form has it's own table containing a field and a primary key (provided by Access). The MainForm links the tables (via the field) with a one-to-many relationship.

The pop-up option group (with option buttons) form (called PopUpTestClassForm). This selection doesn't have a field associated with it but I used the wizard to create it and had it store the value in the field (called DocClass).

In the MainForm I open the pop up form using a command button (NewRecord) (I don't have the DoCmd.GoToRecord , , acNewRec in there yet.) I have:

Private Sub PopClass_Click()
DoCmd.OpenForm "PopUpTestClassForm" 'this part works.

' need to get user selection from pop-up form into _ appropriate field in main form. Nothing has worked. :(
(GetSelection, changing focus, etc., etc., etc., The Controls Property and OpenArgs show promise but I don't understand enough to get them to work.) I don't know what combinations of commands to use.

'[Classification] = Me.DocClass ' :(
'DoCmd.Close 'This works.


The code in the PopupTestClassForm is

Public DocClass As Variant
Option Compare Database
______________________________________

Private Sub Form_AfterUpdate()

If Me.DocClass.Value = 1 Then
Me.DocClass = UNCLASSIFIED
ElseIf Me.DocClass.Value = 2 Then
Me.DocClass = UNCLASSIFIED/FOUO
Else: Me.DocClass = SomethingElse 'just to get it working
End If
[DocClass] = Me.DocClass 'shows numerical value only.
End Sub

A full example would be very helpful. I am not much of a programmer and particularly weak at declairing things.

One other thing. Although I do not get any errors when i run the "code" (without trying to pass data), when i try and close the PopUpTestClassForm manually, I get an error that reads: "The Expression After Update you entered as the event property setting produced the following error: Member already exists in an object module from which this object module derives." I can't find where it exists. May be the result of so many iterations in the VBA? I could re-create the forms from scratch? (Separate issue?)

I'm sorry for asking such fundamental questions, I have exhausted all other resources.

Thank you for taking time with this.

V/R,
55
 
You shouldn't have a public variable with the same name as a control in your form.
You may try something like this:
Code:
Private Sub Form_AfterUpdate()
With Forms![your main form]![classification control]
  If Me!DocClass.Value = 1 Then
    .Value = "UNCLASSIFIED"
  ElseIf Me!DocClass.Value = 2 Then
    .Value = "UNCLASSIFIED/FOUO"
  Else
    .Value = "SomethingElse"
  End If
End With
End Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you PH,

I very much appreciate your help and time. :)

V/R,
55
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top