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

transfereing data form one form to the other

Status
Not open for further replies.

Dina01

Programmer
Mar 26, 2002
204
CA
I have a form that when you click on the cmd button it will transfer the value of the text box to the other form.

This is the code I used....

Forms![PCV_Dispatch_form]![txtCodeSupervisor].Value = Me![txtCodeSupervisor].Value

When I look at the PCV_Dispatch_form I see that the value was transfered, but then what I would like to do is store the value in txtCodeSupervisor.

So I add the following in the PCV_Dispatch_form..
***************

Private Sub Form_Open(Cancel As Integer)

Public strCodeSupervisor As Integer
strCodeSupervisor = Me![txtCodeSupervisor].Value

end sub

But I keep on getting error that it can't contain a Null Value...Why is it that my value is not storing in my strCodeSupervior..

Can anyone please help..

Thanks in advance
 
For a start, use

Forms![PCV_Dispatch_form]!txtCodeSupervisor = Me!txtCodeSupervisor

the .value is unnecessary.

In order for the code above to work you must ALREADY have form PCV_Dispatch_form open

Therefore, the On_Open event has already occured.

When it did occure, the contents of txtCodeSupervisor was NULL. That is okay in itself. However, strCodeSupervisor is of type Integer and CANNOT contain Null
WHY HAVE YOU GOT AN INTEGER VARIABLE STARTING WITH THE STRING TAG "str" :-(



Solutions
Option 1
strCodeSupervisor = Nz(Me!txtCodeSupervisor,"")

will get rid of the error in the On_Open but will not actually set strCodeSupervisor to anything useful.

Option 2
Place the strCodeSupervisor line immediately after the other line of code in the original form
Eg
In the original Form

Public strCodeSupervisor As Integer

Forms![PCV_Dispatch_form]!txtCodeSupervisor = Me!txtCodeSupervisor
strCodeSupervisor = Me!txtCodeSupervisor


( WHY do you need a PUBLIC variable version of CodeSupervisor anyway?
It will always be available as long as the Form is open using the fully referenced control name.)


'ope-that-'elps.


G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
Thank You that worked great......


Thank You so much
 
Hello Litel Smudge,

I though it was working fine but it still doesn't I keep on getting the value "0" no matter what......

What I would like to do is that
my first form is named Ecran_PCP_form I have a textbo named txtCodeSupervisor that will display a number 0, 1 or 2. The when the user click on the Menu1_Click button a second form opens.

The name of the second form is PCV_Dispatch_form, this form also has a textbox named txtCodeSupervisor that passes the value from the first form to the second.

I can see the value in the second form but then in my second form I have the following code that needs to execute.

Private Sub Form_Load()

'Specifies codes to agents

'Verifies the computer name and gives access.
intCodeSupervisor = Me!txtCodeSupervisor

If (intCodeSupervisor = "0" Or "2") Then

MsgBox ("Agent and at employee entrance")

Me![DataID].Visible = False
Me![Agent].Visible = False
Me![Btn_HrsFinCall].Visible = False
Me![Btn_Pause_View].Visible = False
Me![Btn_Pause].Visible = False


Else
'NOTHING
End If

End Sub

But I keep on getting a NULL value....I think the form opens before it an see the value, but I have no idea how to fix this...

I also have the following code in the first form named Ecran_PCP_form
**********************************
Private Sub Btn_MainMenu1_Click()
Forms![PCV_Dispatch_form]!txtCodeSupervisor = Me!txtCodeSupervisor
intCodeSupervisor = Me!txtCodeSupervisor

End Sub
***********************************


Thanks for all your help
 
In the code in the first form that opens the second form add the value to the OpenArgs parameter

Eg
DoCmd.OpenForm "PCV_Dispatch_form", , , , , , txtCodeSupervisor


Then in the code OnLoad of the second form use

'Verifies the computer name and gives access.
intCodeSupervisor = OpenArgs


'ope-that-'elps.



G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
Hello Little Smudge

I was wondering if I can send you a little copy of my db. I tried everything you told me to and it still gives me value Null...

Let me know
 
I'm off for the weekend now ( Don't work here on Fridays most weeks ) - so I'll have a look at it on Monday.





G LS
accessaceNOJUNK@valleyalley.co.uk
Remove the NOJUNK to use.

Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! :-D

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top