Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2005

Tip: Looking for answers? Try searching our database.

linking forms and adding a record

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Emma - 19 Nov 2005 21:11 GMT
I am entering data into to forms.

I have a Master_Jobs form I have an Account_No field and a drop down list
for the Job_type field where when I select a particular job type, in this
instance it would be "New Contract" a form with Contract Type Option box.  
There are 3 options on this form, and when one is selected, in this case,
"BPV Contract", the BPV Contract form opens in add record mode.  

From the Master_Jobs form, I would like the Master_Jobs!Account_No to appear
in the Frm_BPV_Contract!Account_No field.

Can anyone give me clue as to how I can accomplish this?

I have tried creating a variable named Current_Contract_No and saving the
value from Master_Jobs!Account_No

as follows:

Current_AccountNo = Master_Jobs!Account_No.value

But Current_Contract_No is coming up empty when I try to put the value into
Frm_BPV_Contract!CDBPV_Account_No as follows

Private Sub Frame_Contract_Type_Option_AfterUpdate()

Select Case Me!Frame_Contract_Type_Option

   Case 1

       DoCmd.OpenForm "frm_contract_data_BPV", , , , acFormAdd
       If Not IsNull(current_AccountNo) Then
       CDBPV_Account_No = current_AccountNo
       End If
           
   Case 2 . . .

 Is this the wrong place to do this?

Any help would be appreciated.

Thank you,

Emma
MtnView - 19 Nov 2005 23:18 GMT
Hello,

If I understand your question, the field can be passed to the form in
the OpenArgs parameter like:

DoCmd.OpenForm "frm_contract_data_BPV", , , ,
acFormAdd,,Current_AccountNo

Then in your frm_contract_data, use the Form's OnOpen or OnLoad event
to retrieve the data like this:

Me!CDBPV_Account_No = Me.OpenArgs
Emma - 21 Nov 2005 16:20 GMT
Would this also work if the form being opened from frm_tbl_Master_Jobs is not
the form where I need Account_No?  I am opening a frm_Contract_Option before
I open the frm_contract_data_BPV and frm_contract_data_BPV is where I need
the Account_no field from tbl_Master_Jobs.

I guess what I am asking is, does the OpenArgs parameter keep the value
until I clear it?

> Hello,
>
[quoted text clipped - 8 lines]
>
> Me!CDBPV_Account_No = Me.OpenArgs
MtnView - 23 Nov 2005 01:55 GMT
Hello,

The OpenArgs parameter passes data only to the form that it opens in
the DoCmd.OpenForm statement. If one form opens the next, you could
pass it along again.

Or, you might try using a Public variable in a module (from the
database window). It's not highly recommended in structured
programming, but it works. These Public variables normally can be
accessed from code in any form. If you use this method, try to identify
them clearly, so they will not get confused with variables in form
modules. I usually name them something like GlobalVarCurrent_AccountNo.

You could also create a table for GlobalVariables on the front-end of
your database.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.