Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

How do you get the program to remember the selected person from form to form using a VB/Access database?

I am trying to create a database program where the opening VB form selects the person they wish to update.  I want to be able to go from form to form with that person (person and id# are the key for each table) selected on the opening form to appear on each additional form rather than have the first person appearing on the access database to pop up.   What code do I need to include?  This is for a Visual Basic/Access database with several vb forms and access tables.
0
jclaire
Asked:
jclaire
1 Solution
 
MisledmanCommented:
Make a global variable in a module. Set the variable to the value chosen on the opening form. During form load of all the rest, set your parameters, whatever they may be, to those variables.

Such as :

private sub Form_Load ()

cboComboName.text = mvarName
cboComboID.text = mvarID

end sub

This may not be enough info. Let me know....
0
 
HelixDaKatCommented:
I agree with Misledman
0
 
MisledmanCommented:
Do you need code to reposition tables/querys? If so, you using bound or unbound controls?
0
 
PNJCommented:
I agree, but I think Form_ACTIVATE event - rather than Form_LOAD to set the variables, that way if the form is already loaded and the user flicks betweens screens the data will be refreshed automatically:

Viz:
Private Sub Form_Activate()
   cboComboName.text = mvarName
   cboComboID.text = mvarID
End Sub

0
 
corvanderlindenCommented:
In my opinion better options :

1. Make a global Type in a module

Type Person
  name As String
  id   As Long
End Type

Dim myPerson As Person


2. To keep everything more OO make a class CPerson
   advantage is that a class is easily extendible

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now