Passing values betwwen forms 
Author Message
 Passing values betwwen forms

Hi,
I need some help with this logic.

Here I have a form that has a list box and opens a new
form depending on the value of the listbox.There are no
subforms. This master form say frmLocation also has a
field RecordID which is autonumber and unique and needs to
be passed on to the subsequent forms like frmBoreHole and
frmWater. Can somebody please tell me how do I do it.
I tried the foillowing syntax..Please advise where I am
going wrong

Private Sub Combobox_AfterUpdate()

Select Case Combobox
    Case 1
        DoCmd.OpenForm "frmBoreHole", , , , , , RecordID
    Case 2
        DoCmd.OpenForm "frmWater"
    Case 3
        DoCmd.OpenForm "frmRadon"
End Select

End Sub

Private Sub frmBoreHole_Open()
If IsNumeric(RecordID) = True Then
BOREHOLEDATASOURCE_RecordID.DefaultValue = Val(RecordID)

End Sub

Thaks a lot for your help
Dan



Mon, 29 Aug 2005 05:23:50 GMT  
 Passing values betwwen forms
Dan,

1) You have to add the OpenArgs to each OpenForm statement.
I am using your number values, so I hope the value returned
by the Combo Box is the ID number of the form, not text.

Private Sub Combobox_AfterUpdate()
 Select Case Combobox
     Case is = 1
         DoCmd.OpenForm "frmBoreHole", , , , , , RecordID
     Case is = 2
         DoCmd.OpenForm "frmWater", , , , , , RecordID
     Case is = 3
         DoCmd.OpenForm "frmRadon", , , , , , RecordID
   End Select
 End Sub

2) You must use the Form Load event to read the OpenArgs, not the Open
event.

 Private Sub Form_Load()

3)   --> not needed  ' If IsNumeric(RecordID) = True Then <--
     ' Is there a chance that the OpenArgs will be Null
     ' (i.e. if opened from the database window)
     ' If so

If IsNull(Me.OpenArgs) Then
Else
 BOREHOLEDATASOURCE_RecordID.DefaultValue = val(Me.OpenArgs)
End If

End Sub

I've used your terminology BOREHOLEDATASOURCE_RecordID"
but the form opened, using your Select Case is frmBoreHole.
So is the name of the control [BOREHOLEDATASOURCE_RecordID] or is it
[RecordID]?
Or did you put the name of a form together with the name of the Control?
Hard for me to tell.

3a) In any event the correct terminology for that DefaultValue statement
would be.

 Me![TheControlName].DefaultValue = Val(Me.OpenArgs)

--
Fred

Please reply only to this newsgroup.
I do not reply to personal e-mail.


Quote:
> Hi,
> I need some help with this logic.

> Here I have a form that has a list box and opens a new
> form depending on the value of the listbox.There are no
> subforms. This master form say frmLocation also has a
> field RecordID which is autonumber and unique and needs to
> be passed on to the subsequent forms like frmBoreHole and
> frmWater. Can somebody please tell me how do I do it.
> I tried the foillowing syntax..Please advise where I am
> going wrong

> Private Sub Combobox_AfterUpdate()

> Select Case Combobox
>     Case 1
>         DoCmd.OpenForm "frmBoreHole", , , , , , RecordID
>     Case 2
>         DoCmd.OpenForm "frmWater"
>     Case 3
>         DoCmd.OpenForm "frmRadon"
> End Select

> End Sub

> Private Sub frmBoreHole_Open()
> If IsNumeric(RecordID) = True Then
> BOREHOLEDATASOURCE_RecordID.DefaultValue = Val(RecordID)

> End Sub

> Thaks a lot for your help
> Dan



Mon, 29 Aug 2005 07:58:16 GMT  
 Passing values betwwen forms
Hi Fred,
thanks for everything!!!
I just have minor doubts in syntax ..I would really
appreciate it if you could help me with those...As I dont
seem to clearly understand teh scope of Me in your code.
Please follow my note sin capital letters.

Quote:
>-----Original Message-----
>Dan,

>1) You have to add the OpenArgs to each OpenForm
statement.
>I am using your number values, so I hope the value
returned
>by the Combo Box is the ID number of the form, not text.

>Private Sub Combobox_AfterUpdate()
> Select Case Combobox
>     Case is = 1
>         DoCmd.OpenForm "frmBoreHole", , , , , , RecordID
>     Case is = 2
>         DoCmd.OpenForm "frmWater", , , , , , RecordID
>     Case is = 3
>         DoCmd.OpenForm "frmRadon", , , , , , RecordID
>   End Select
> End Sub

I HAVE DONE THIS PART...

Quote:
>2) You must use the Form Load event to read the OpenArgs,
not the Open
>event.

> Private Sub Form_Load()

>3)   --> not needed  ' If IsNumeric(RecordID) = True Then
<--
>     ' Is there a chance that the OpenArgs will be Null
>     ' (i.e. if opened from the database window)
>     ' If so

I HAVE DONE TILL HERE

Quote:
>If IsNull(Me.OpenArgs) Then
>Else
> BOREHOLEDATASOURCE_RecordID.DefaultValue = val
(Me.OpenArgs)
>End If

>End Sub

THE CODE THAT I WROTE FROM YOUR CODE IS

Private Sub Form_Load()
If IsNull(frmLocation.RecordID) Then
Else
 frmBoreHole!BOREHOLEDATASOURCE_RecordID.DefaultValue = Val
(frmLocation.RecordID)
End If

End Sub

Quote:

>I've used your terminology BOREHOLEDATASOURCE_RecordID"
>but the form opened, using your Select Case is
frmBoreHole.
>So is the name of the control

[BOREHOLEDATASOURCE_RecordID] or is it
Quote:
>[RecordID]?
>Or did you put the name of a form together with the name
of the Control?
>Hard for me to tell.
>THE FORM IS frmBoreHole AND TEH CONTROL IS

BOREHOLEDATASOURCE_RecordID
Quote:
>3a) In any event the correct terminology for that

DefaultValue statement
Quote:
>would be.

> Me![TheControlName].DefaultValue = Val(Me.OpenArgs)

>--
>Fred

HOPE YOU CAN UNDERSTANFD MY QUESTION
PLEASE LET ME KNOW WHERE IAM GOING WRONG IN CONVERTING
YOUR CODE TO MINE

Thanks alot for your help
Dan

- Show quoted text -

Quote:

>Please reply only to this newsgroup.
>I do not reply to personal e-mail.



>> Hi,
>> I need some help with this logic.

>> Here I have a form that has a list box and opens a new
>> form depending on the value of the listbox.There are no
>> subforms. This master form say frmLocation also has a
>> field RecordID which is autonumber and unique and needs
to
>> be passed on to the subsequent forms like frmBoreHole
and
>> frmWater. Can somebody please tell me how do I do it.
>> I tried the foillowing syntax..Please advise where I am
>> going wrong

>> Private Sub Combobox_AfterUpdate()

>> Select Case Combobox
>>     Case 1
>>         DoCmd.OpenForm "frmBoreHole", , , , , , RecordID
>>     Case 2
>>         DoCmd.OpenForm "frmWater"
>>     Case 3
>>         DoCmd.OpenForm "frmRadon"
>> End Select

>> End Sub

>> Private Sub frmBoreHole_Open()
>> If IsNumeric(RecordID) = True Then
>> BOREHOLEDATASOURCE_RecordID.DefaultValue = Val(RecordID)

>> End Sub

>> Thaks a lot for your help
>> Dan

>.



Mon, 29 Aug 2005 08:25:17 GMT  
 Passing values betwwen forms
HI Fred,
The cod ethat you gave me worked perfectly.
thank you so much.
Could you please tell me how to update RecordID in a
subform say subfrmOrganic with the recordID in frmBoreHole.
as this subform has 1 to many relationship.

Sincerely,
Dan

Quote:
>-----Original Message-----
>Dan,

>1) You have to add the OpenArgs to each OpenForm
statement.
>I am using your number values, so I hope the value
returned
>by the Combo Box is the ID number of the form, not text.

>Private Sub Combobox_AfterUpdate()
> Select Case Combobox
>     Case is = 1
>         DoCmd.OpenForm "frmBoreHole", , , , , , RecordID
>     Case is = 2
>         DoCmd.OpenForm "frmWater", , , , , , RecordID
>     Case is = 3
>         DoCmd.OpenForm "frmRadon", , , , , , RecordID
>   End Select
> End Sub

>2) You must use the Form Load event to read the OpenArgs,
not the Open
>event.

> Private Sub Form_Load()

>3)   --> not needed  ' If IsNumeric(RecordID) = True Then
<--
>     ' Is there a chance that the OpenArgs will be Null
>     ' (i.e. if opened from the database window)
>     ' If so

>If IsNull(Me.OpenArgs) Then
>Else
> BOREHOLEDATASOURCE_RecordID.DefaultValue = val
(Me.OpenArgs)
>End If

>End Sub

>I've used your terminology BOREHOLEDATASOURCE_RecordID"
>but the form opened, using your Select Case is
frmBoreHole.
>So is the name of the control

[BOREHOLEDATASOURCE_RecordID] or is it
Quote:
>[RecordID]?
>Or did you put the name of a form together with the name
of the Control?
>Hard for me to tell.

>3a) In any event the correct terminology for that

DefaultValue statement

- Show quoted text -

Quote:
>would be.

> Me![TheControlName].DefaultValue = Val(Me.OpenArgs)

>--
>Fred

>Please reply only to this newsgroup.
>I do not reply to personal e-mail.



>> Hi,
>> I need some help with this logic.

>> Here I have a form that has a list box and opens a new
>> form depending on the value of the listbox.There are no
>> subforms. This master form say frmLocation also has a
>> field RecordID which is autonumber and unique and needs
to
>> be passed on to the subsequent forms like frmBoreHole
and
>> frmWater. Can somebody please tell me how do I do it.
>> I tried the foillowing syntax..Please advise where I am
>> going wrong

>> Private Sub Combobox_AfterUpdate()

>> Select Case Combobox
>>     Case 1
>>         DoCmd.OpenForm "frmBoreHole", , , , , , RecordID
>>     Case 2
>>         DoCmd.OpenForm "frmWater"
>>     Case 3
>>         DoCmd.OpenForm "frmRadon"
>> End Select

>> End Sub

>> Private Sub frmBoreHole_Open()
>> If IsNumeric(RecordID) = True Then
>> BOREHOLEDATASOURCE_RecordID.DefaultValue = Val(RecordID)

>> End Sub

>> Thaks a lot for your help
>> Dan

>.



Mon, 29 Aug 2005 09:14:58 GMT  
 Passing values betwwen forms
Dan,

You will not have to do anything at all to update the RecordID on the
subform.  As long as you have the subform's LinkMasterFields and
LinkChildFields properties correctly set, the RecordID will take care
of itself.  That's one of the joys of subforms.

- Steve Schapel, Microsoft Access MVP

Quote:

>HI Fred,
>The cod ethat you gave me worked perfectly.
>thank you so much.
>Could you please tell me how to update RecordID in a
>subform say subfrmOrganic with the recordID in frmBoreHole.
>as this subform has 1 to many relationship.

>Sincerely,
>Dan

>>-----Original Message-----
>>Dan,

>>1) You have to add the OpenArgs to each OpenForm
>statement.
>>I am using your number values, so I hope the value
>returned
>>by the Combo Box is the ID number of the form, not text.

>>Private Sub Combobox_AfterUpdate()
>> Select Case Combobox
>>     Case is = 1
>>         DoCmd.OpenForm "frmBoreHole", , , , , , RecordID
>>     Case is = 2
>>         DoCmd.OpenForm "frmWater", , , , , , RecordID
>>     Case is = 3
>>         DoCmd.OpenForm "frmRadon", , , , , , RecordID
>>   End Select
>> End Sub

>>2) You must use the Form Load event to read the OpenArgs,
>not the Open
>>event.

>> Private Sub Form_Load()

>>3)   --> not needed  ' If IsNumeric(RecordID) = True Then
><--
>>     ' Is there a chance that the OpenArgs will be Null
>>     ' (i.e. if opened from the database window)
>>     ' If so

>>If IsNull(Me.OpenArgs) Then
>>Else
>> BOREHOLEDATASOURCE_RecordID.DefaultValue = val
>(Me.OpenArgs)
>>End If

>>End Sub

>>I've used your terminology BOREHOLEDATASOURCE_RecordID"
>>but the form opened, using your Select Case is
>frmBoreHole.
>>So is the name of the control
>[BOREHOLEDATASOURCE_RecordID] or is it
>>[RecordID]?
>>Or did you put the name of a form together with the name
>of the Control?
>>Hard for me to tell.

>>3a) In any event the correct terminology for that
>DefaultValue statement
>>would be.

>> Me![TheControlName].DefaultValue = Val(Me.OpenArgs)

>>--
>>Fred

>>Please reply only to this newsgroup.
>>I do not reply to personal e-mail.



>>> Hi,
>>> I need some help with this logic.

>>> Here I have a form that has a list box and opens a new
>>> form depending on the value of the listbox.There are no
>>> subforms. This master form say frmLocation also has a
>>> field RecordID which is autonumber and unique and needs
>to
>>> be passed on to the subsequent forms like frmBoreHole
>and
>>> frmWater. Can somebody please tell me how do I do it.
>>> I tried the foillowing syntax..Please advise where I am
>>> going wrong

>>> Private Sub Combobox_AfterUpdate()

>>> Select Case Combobox
>>>     Case 1
>>>         DoCmd.OpenForm "frmBoreHole", , , , , , RecordID
>>>     Case 2
>>>         DoCmd.OpenForm "frmWater"
>>>     Case 3
>>>         DoCmd.OpenForm "frmRadon"
>>> End Select

>>> End Sub

>>> Private Sub frmBoreHole_Open()
>>> If IsNumeric(RecordID) = True Then
>>> BOREHOLEDATASOURCE_RecordID.DefaultValue = Val(RecordID)

>>> End Sub

>>> Thaks a lot for your help
>>> Dan

>>.



Wed, 31 Aug 2005 11:58:58 GMT  
 Passing values betwwen forms
Dan,

Just to add to Fred's excellent advice, an alternative, arguably
simpler, method would be...

Private Sub Combobox_AfterUpdate()
  Select Case Combobox
     Case 1
         DoCmd.OpenForm "frmBoreHole"
         Forms!frmBoreHole!RecordID.DefaultValue = Me.RecordID
     Case 2
         DoCmd.OpenForm "frmWater"
etc...

Either way, though, as I've mentioned to you before a number of times,
you've still got a problem as regards whether there is already a Data
record corresponding to the current Location record, or whether you
are making a new one.

- Steve Schapel, Microsoft Access MVP

Quote:

>Dan,

>1) You have to add the OpenArgs to each OpenForm statement.
>I am using your number values, so I hope the value returned
>by the Combo Box is the ID number of the form, not text.

>Private Sub Combobox_AfterUpdate()
> Select Case Combobox
>     Case is = 1
>         DoCmd.OpenForm "frmBoreHole", , , , , , RecordID
>     Case is = 2
>         DoCmd.OpenForm "frmWater", , , , , , RecordID
>     Case is = 3
>         DoCmd.OpenForm "frmRadon", , , , , , RecordID
>   End Select
> End Sub

>2) You must use the Form Load event to read the OpenArgs, not the Open
>event.

> Private Sub Form_Load()

>3)   --> not needed  ' If IsNumeric(RecordID) = True Then <--
>     ' Is there a chance that the OpenArgs will be Null
>     ' (i.e. if opened from the database window)
>     ' If so

>If IsNull(Me.OpenArgs) Then
>Else
> BOREHOLEDATASOURCE_RecordID.DefaultValue = val(Me.OpenArgs)
>End If

>End Sub

>I've used your terminology BOREHOLEDATASOURCE_RecordID"
>but the form opened, using your Select Case is frmBoreHole.
>So is the name of the control [BOREHOLEDATASOURCE_RecordID] or is it
>[RecordID]?
>Or did you put the name of a form together with the name of the Control?
>Hard for me to tell.

>3a) In any event the correct terminology for that DefaultValue statement
>would be.

> Me![TheControlName].DefaultValue = Val(Me.OpenArgs)



Wed, 31 Aug 2005 12:05:24 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Form to Subform to popup form and pass value

2. Command to pass Unbound Value on Form to Filter Sub Form Query

3. passing values from a form to a query for another form

4. Passing a value from form to form

5. To pass values of a form for another form

6. Passing Values from Form to Form

7. Passing a value from one form to a specific field on another form

8. Passing two values from a form to another form

9. Passing a value from one form to a specific field on another form

10. Passing multiple field values to a query from a form (flexi form)


 
Powered by phpBB® Forum Software © phpBB Group