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

Input new form value on main form 1

Status
Not open for further replies.

haerion

IS-IT--Management
Sep 13, 2006
130
0
0
US
Hi Guys,

I have a vba code which need a value I need to select from another form.

What I wanna do is click on a command on my main form that will open a form which have an option group command, then the user select the option he needs, click the ok button then the form close and the code continue using the value that was selected.

Thank you,

Haerion
 
Why not set the value in a global variable in which to call on the new form?
 

If you close the 2nd form without first saving the value you obtained, it's gone. Store it somewhere or keep the form open -- maybe hidden?


Randy
 
The best method
1. Pop open the form in the dialog mode. This stops code execution in the calling form until you close the pop up form.
2. On the pop up put an ok, cancel buttons
3. in the cancel button close the form
4. in the ok button hide the form (make it invisible)
at this point the code in the calling form continues
5. the code continues. Check to see if the pop up is loaded
if currentproject.allforms("popupName").isloaded then
you can get the value from the loaded but hidden form
someValue = forms("popupName").somecontrol
end if

if you hit cancel on the popup then nothing happens
 
In step 5, after getting the value from the hidden form you then need to close it.
docmd.close acform, "popupName
 
Thank you MajP, everything works perfect now :)

here is my final code:

Dim StoreNo As String
DoCmd.OpenForm "StoreNo", acAdd, , , , acDialog

If CurrentProject.AllForms("StoreNo").IsLoaded Then
StoreNo = Forms("StoreNo").ChkStoreNo
Else
StoreNo = "99"
End If

AppActivate ("Versys - NITerm")

SendKeys "^x"
SendKeys StoreNo
DoCmd.Close acForm, "StoreNo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top