A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

passing a value / type mismatch



 
 
Thread Tools Display Modes
  #1  
Old June 1st, 2004, 07:30 PM
DanielS
external usenet poster
 
Posts: n/a
Default passing a value / type mismatch

I know this question has been asked before because I have
read the responses and tried the suggestions, but I am
still stuck.
I have a series of 10 forms set up for gathering
information about a certain manufacturer. The user
enters the manufacturer's name on the first form and then
I want all of the following forms to display that name
(so it is very clear for my users what company they are
entering information for). So basically, I need to pass
the value to the next form and display it there. Please
help!
Below is the most recent trick I tried, but it didn't
work:
(I know it didn't work because on I never have a value
displayed on Form 2, and as soon as the AfterUpdate is
run on Form 1, I get a type mismatch error).

Form 1:

Option Compare Database

'Current Manufacturer variable
Dim strCurrMfr As String

Public Function CurrMfr() As String

'Public Function stores value of private variable
CurrMfr = strCurrMfr

End Function

Private Sub MfrName_AfterUpdate()
On Error GoTo Err_MfrName_AfterUpdate

'set Current Manufacturer Variable
strCurrMfr = Str(Me.MfrName.Value)

CurrMfr

Exit_MfrName_AfterUpdate:
Exit Sub

Err_MfrName_AfterUpdate:
MsgBox Err.Description
Resume Exit_MfrName_AfterUpdate

End Sub


Form 2:
I have an unbound text box where Control Source: =CurrMfr
()


  #2  
Old June 2nd, 2004, 01:45 AM
Graham R Seach
external usenet poster
 
Posts: n/a
Default passing a value / type mismatch

Daniel,

Assuming Form1 calls Form2, and so on, why not just use the OpenArgs
argument of the OpenForm method:

DoCmd.OpenForm "Form2", , , , , , strCurrMfr

Then in Form2's Open method, you can retrieve the OpenArgs value:

strCurrMfr = Me.OpenArgs

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyT...764559036.html


"DanielS" wrote in message
...
I know this question has been asked before because I have
read the responses and tried the suggestions, but I am
still stuck.
I have a series of 10 forms set up for gathering
information about a certain manufacturer. The user
enters the manufacturer's name on the first form and then
I want all of the following forms to display that name
(so it is very clear for my users what company they are
entering information for). So basically, I need to pass
the value to the next form and display it there. Please
help!
Below is the most recent trick I tried, but it didn't
work:
(I know it didn't work because on I never have a value
displayed on Form 2, and as soon as the AfterUpdate is
run on Form 1, I get a type mismatch error).

Form 1:

Option Compare Database

'Current Manufacturer variable
Dim strCurrMfr As String

Public Function CurrMfr() As String

'Public Function stores value of private variable
CurrMfr = strCurrMfr

End Function

Private Sub MfrName_AfterUpdate()
On Error GoTo Err_MfrName_AfterUpdate

'set Current Manufacturer Variable
strCurrMfr = Str(Me.MfrName.Value)

CurrMfr

Exit_MfrName_AfterUpdate:
Exit Sub

Err_MfrName_AfterUpdate:
MsgBox Err.Description
Resume Exit_MfrName_AfterUpdate

End Sub


Form 2:
I have an unbound text box where Control Source: =CurrMfr
()




  #3  
Old June 2nd, 2004, 07:41 PM
external usenet poster
 
Posts: n/a
Default passing a value / type mismatch

Graham,

Thank you so much! That was brilliant!
Another question...I also have a button to add a new
record. Any idea how to pass the same value and display
it on the new record? Since we aren't exactly opening a
new form, there aren't OpenArgs.

Thanks,
Daniel

-----Original Message-----
Daniel,

Assuming Form1 calls Form2, and so on, why not just use

the OpenArgs
argument of the OpenForm method:

DoCmd.OpenForm "Form2", , , , , , strCurrMfr

Then in Form2's Open method, you can retrieve the

OpenArgs value:

strCurrMfr = Me.OpenArgs

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-

0764559036.html


"DanielS" wrote in

message
...
I know this question has been asked before because I

have
read the responses and tried the suggestions, but I am
still stuck.
I have a series of 10 forms set up for gathering
information about a certain manufacturer. The user
enters the manufacturer's name on the first form and

then
I want all of the following forms to display that name
(so it is very clear for my users what company they are
entering information for). So basically, I need to pass
the value to the next form and display it there. Please
help!
Below is the most recent trick I tried, but it didn't
work:
(I know it didn't work because on I never have a value
displayed on Form 2, and as soon as the AfterUpdate is
run on Form 1, I get a type mismatch error).

Form 1:

Option Compare Database

'Current Manufacturer variable
Dim strCurrMfr As String

Public Function CurrMfr() As String

'Public Function stores value of private variable
CurrMfr = strCurrMfr

End Function

Private Sub MfrName_AfterUpdate()
On Error GoTo Err_MfrName_AfterUpdate

'set Current Manufacturer Variable
strCurrMfr = Str(Me.MfrName.Value)

CurrMfr

Exit_MfrName_AfterUpdate:
Exit Sub

Err_MfrName_AfterUpdate:
MsgBox Err.Description
Resume Exit_MfrName_AfterUpdate

End Sub


Form 2:
I have an unbound text box where Control Source:

=CurrMfr
()




.

  #4  
Old June 2nd, 2004, 11:26 PM
DanielS
external usenet poster
 
Posts: n/a
Default passing a value / type mismatch

Scratch that last request. I realized that you can still
access the forms OpenArgs when you go to the new record.
Thank you once again for you help.


-----Original Message-----
Graham,

Thank you so much! That was brilliant!
Another question...I also have a button to add a new
record. Any idea how to pass the same value and display
it on the new record? Since we aren't exactly opening a
new form, there aren't OpenArgs.

Thanks,
Daniel

-----Original Message-----
Daniel,

Assuming Form1 calls Form2, and so on, why not just use

the OpenArgs
argument of the OpenForm method:

DoCmd.OpenForm "Form2", , , , , , strCurrMfr

Then in Form2's Open method, you can retrieve the

OpenArgs value:

strCurrMfr = Me.OpenArgs

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-

0764559036.html


"DanielS" wrote in

message
.. .
I know this question has been asked before because I

have
read the responses and tried the suggestions, but I am
still stuck.
I have a series of 10 forms set up for gathering
information about a certain manufacturer. The user
enters the manufacturer's name on the first form and

then
I want all of the following forms to display that name
(so it is very clear for my users what company they are
entering information for). So basically, I need to pass
the value to the next form and display it there.

Please
help!
Below is the most recent trick I tried, but it didn't
work:
(I know it didn't work because on I never have a value
displayed on Form 2, and as soon as the AfterUpdate is
run on Form 1, I get a type mismatch error).

Form 1:

Option Compare Database

'Current Manufacturer variable
Dim strCurrMfr As String

Public Function CurrMfr() As String

'Public Function stores value of private variable
CurrMfr = strCurrMfr

End Function

Private Sub MfrName_AfterUpdate()
On Error GoTo Err_MfrName_AfterUpdate

'set Current Manufacturer Variable
strCurrMfr = Str(Me.MfrName.Value)

CurrMfr

Exit_MfrName_AfterUpdate:
Exit Sub

Err_MfrName_AfterUpdate:
MsgBox Err.Description
Resume Exit_MfrName_AfterUpdate

End Sub


Form 2:
I have an unbound text box where Control Source:

=CurrMfr
()




.

.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:23 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.