Copying one data field to another.

Jofffox

Registered User.
Local time
Today, 02:18
Joined
Feb 26, 2008
Messages
12
Hi,

i am having problems copying one data field from one form to another. I would like users to type in their user number in the switchboard and then this number to prepopulate the other sub forms.


i have enclosed and example, any help would be greatly apreciated.

thanks,

Jon
 

Attachments

Use a global variable to store this number and when opening other forms check the global value.
 
How do i implement this global variable? sorry im pretty new to this. just in simple terms relating to my example above if possible. then hopefully i can apply this to my db!
thanks again!
Jon
 
create a module. Put this in the module
Code:
option compare database
option explicit

dim MyGlobalVariable as Integer ' Or Long Or Boolean Or ...
Enjoy!
 
There are a lot of ways you can accomplish this. A Global Variable is one way but if you prefer not to go that route then you may want to try this:

Place the contents of the Switchboard TextBox into the OpenArgs property when opening the Form. For example:

DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd, , Nz(Me.Text1, Null)

The Nz() function ensures that Null is passed if nothing is within the SwitchBoard TextBox and the Open Form button is selected.

Then you need to add a wee bit of code into the the OnCurrent event of the DEtails Form:

Code:
Private Sub Form_Current()
   If Nz(Me.OpenArgs, "") > "" And Me.NewRecord = True Then
      Me.nametxt = Me.OpenArgs
   End If
End Sub

Notice that I renamed the Name TextBox in the DEtails Form from name to nametxt. Name is a reserved word and you shouldn't be using it. Yes...you can perhaps get away with it now....but that sort of thing will byte you hard later on.

Also...Keep in mind that the Form must be opened for adding a New record only for this to work.

.
 
Thats a great help!

one more point though, as i am very poor at access...

How do i implement this 'openarg' on the switchboard's properties? or for the button to open the details form?

how do i code it?

thanks for you help so far!
jon
 

Users who are viewing this thread

Back
Top Bottom