Mind Blank - Pls Help! (1 Viewer)

andy_dyer

Registered User.
Local time
Today, 22:08
Joined
Jul 2, 2003
Messages
806
Hi,

I'm trying to build something that started life as quite simple but now has grown and grown and grown...

I have a form for projects and a subform form that holds finance details i.e. top level budget etc

On this subform I have a button to open a detail sub-sub-form which shows the annual breakdown and has a button to add new years...

Then on this sub-sub-sub-form is where my challenges arise...

I want the project name, currency and exchange rate to pull through from other forms and they are not currently - I am using this code to try and pull the project ID and Currency ID through

Code:
Private Sub Form_Load()

    Dim intProjectID As Integer
    Dim intCurrencyID As Integer
            
    On Error Resume Next ' OpenArgs might be empty
    

    If Not IsNull(Me.OpenArgs) Then
        intProjectID = CInt(Me.OpenArgs) ' ProjectID passed in via OpenArgs parameter in OpenForm method
        cboProjectName.Value = intProjectID
        intCurrencyID = CInt(Me.OpenArgs) ' CurrencyID passed in via OpenArgs parameter in OpenForm method
        cboCurrency.Value = intCurrencyID
    End If
    
End Sub

For the exchange rate this is a calculated field using this code in the control source

Code:
=ExchangeRate([Start Date],[CurrencyID])

This works on other forms but may not work here because the currency isn't pulling through...

I've even tried

Code:
=[Forms]![frmProjectFinance]![txtExchangeRateUsed]

Just to simply pull through from the main form without re-calculating

But currently nothing gets pulled through... :confused:


Any ideas how I can get these pieces of data pulled through would be gratefully received :)
 

boblarson

Smeghead
Local time
Today, 14:08
Joined
Jan 12, 2001
Messages
32,059
You currently have this:
Code:
   If Not IsNull([B][COLOR=red]Me.OpenArgs[/COLOR][/B]) Then
        intProjectID = CInt([B][COLOR=red]Me.OpenArgs[/COLOR][/B]) ' ProjectID passed in via OpenArgs parameter in OpenForm method
        cboProjectName.Value = intProjectID
        intCurrencyID = CInt([B][COLOR=red]Me.OpenArgs[/COLOR][/B]) ' CurrencyID passed in via OpenArgs parameter in OpenForm method
        cboCurrency.Value = intCurrencyID

So how can you be using OpenArgs in two places for two different fields without some processing to the OpenArgs? OpenArgs only takes one value. So, in order to pass multiple items using OpenArgs, you need to use a delimiter and then you have to use the split function to get the parts and assign them to the right place.
 

andy_dyer

Registered User.
Local time
Today, 22:08
Joined
Jul 2, 2003
Messages
806
Hi Bob,

Thanks for taking the time to reply... you may guess that I've neever used openargs before and also have kind of adapted code I've found on the web to get to where I am...

Now realising multiple items in open args is a no no - I looked and found this but don't know if this is what you meant?

http://www.utteraccess.com/forum/OpenArgs-pass-multiple-t1929209.html

I also don't know where to start trying to adapt it for my database...

:confused:
 

vbaInet

AWF VIP
Local time
Today, 22:08
Joined
Jan 22, 2010
Messages
26,374
I want the project name, currency and exchange rate to pull through from other forms and they are not currently -
Can you complete this sentence?

Not currently Open? If that was what you were going to say then it's not possible. You will need to use a recordset or a DLookup() function to pull in data.
 

andy_dyer

Registered User.
Local time
Today, 22:08
Joined
Jul 2, 2003
Messages
806
Can you complete this sentence?

Not currently Open? If that was what you were going to say then it's not possible. You will need to use a recordset or a DLookup() function to pull in data.


Hi - no just that they are not currently pulling through...

All my forms are open... the following hierarchy

1) Master Form (fromProjectMaster) which has an embedded subform that displays different subforms based on button clicks

2) the above embedded subform of interest (frmProjectFinance) which has a button to open a new form with annual totals

3) the above mentioned new form (frmProjectFinanceYear) which has a button to open a new form to add new years to the project finances

4) the ultimate form which I need the data in (frmProjectFinanceYearDetail)

The stored project name and currency along with the calculated exchange rate fields are all on 2) above and I need to pass them to 4)

So the forms are all open just not necessarially 'active'

Does that help?

I've attached a cut down version of my database to show my problem...
 

Attachments

  • Database3.mdb
    1.1 MB · Views: 84
Last edited:

vbaInet

AWF VIP
Local time
Today, 22:08
Joined
Jan 22, 2010
Messages
26,374
Pass the values to form 4) using the Current event and After Update events of form 2).

Code:
Me.Form3!Form4!FieldName
 

andy_dyer

Registered User.
Local time
Today, 22:08
Joined
Jul 2, 2003
Messages
806
Pass the values to form 4) using the Current event and After Update events of form 2).

Code:
Me.Form3!Form4!FieldName

Hi - sorry I'm confused :confused:

I've got this code but it errors saying it cannot find the field named frmprojectmaster... it's nto a field its a form...


Code:
Private Sub Form_Current()
Me.txtExchangeRateUsed = Form!frmprojectmaster!frmprojectfinance!txtExchangeRateUsed

End Sub
 

andy_dyer

Registered User.
Local time
Today, 22:08
Joined
Jul 2, 2003
Messages
806
Ok think I've pieced it together

This may not be the best code but it works!

Code:
Private Sub Form_Current()
    Dim intProjectID As Integer
    Dim intCurrencyID As Integer
    Dim strExchangeRate As String
    
    strExchangeRate = Forms![frmprojectmaster]!sfrData!txtExchangeRateUsed
    intProjectID = Forms![frmprojectmaster]!txtProjectID
    intCurrencyID = Forms![frmprojectmaster]!sfrData!cboCurrency
    
    Me.cboProjectName = intProjectID
    Me.cboCurrency = intCurrencyID
    Me.txtExchangeRateUsed = strExchangeRate
End Sub

Thanks for your help!
 

vbaInet

AWF VIP
Local time
Today, 22:08
Joined
Jan 22, 2010
Messages
26,374
I hope you put it in the After Update event too?
 

andy_dyer

Registered User.
Local time
Today, 22:08
Joined
Jul 2, 2003
Messages
806
I hope you put it in the After Update event too?


Why do I need to? This code is only when a form loads and there is no field on this new form that would trigger an update of these fields...

Or have I missed something :confused:
 

vbaInet

AWF VIP
Local time
Today, 22:08
Joined
Jan 22, 2010
Messages
26,374
Alright, so you just need the values at load time only? That's fine then.
 

Users who are viewing this thread

Top Bottom