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

Can an ID automatically feed in other IDs in other forms?

Status
Not open for further replies.

CCSC0208

Technical User
May 16, 2003
22
US
Hello,

Due the capacity issue, I have to devide a questionnaire into several froms. I want the data entry person to enter the first record from the first form to the last form, then enter the second record. In addition, I hope he only needs to enter the ID for the first time, then when he opens the next form, the ID will automatically show up. He sees the ID and knows it's still the same record, and he will keep entering the remainning information.

What I did is:

In FormA:
Private Sub StudyID_AfterUpdate()
[ID] = [StudyID]
End Sub


In FormB:
Private Sub ID_Enter()
[FormB.ID] = [FormA.ID]
End Sub

But it didn't work. Can somebody help me? Thank you1
 
When you talk about ID, are you talking about a record ID or an ID field you created on your form? If the latter of the 2, you can do this, which is how I have done similar things:

In a module, create the following variable:

Dim strID

In FormA:
Private Sub StudyID_AfterUpdate()
Me!ID = Me!StudyID
strID = me!StudyID
End Sub


In FormB:
Private Sub ID_Enter()
Me!ID = strID
End Sub


---------------------------------------

In my limited experience, 80-90% of all problems brought to my attention can be attributed to PEBCAK...the other 10-20% can be attributed to MS!
 
Put that Code in the Button that open the second form

dim stDocName as string
dim stArgs as string

set stDocName = "FormB"
set stArgs = Me.[ID]
doCmdOpen stDocName,,,,,,stArgs

And put in the On Open of your FormB

if len(Me.OpenArgs > 0) then
Me.[ID] = Me.OpenArgs
ENd If

I think that should work...
 
I am a beginner and have no experience in VBA. Please bear with me.

Where do I put "Dim strID"? Like the following? It didn't work. I have the message that the variable strID is not defined. Could you tell me in more detail? Thank you very much.

Option Compare Database
Option Explicit

Dim strID As Long

other codes...



 
Create a New Module, which you can do under the module button/tab (depending on version of access) and under the Option Explicit line, type in Public strID, not Dim strID. This will make strID a public variable for use throughout your database.

However, you may want to look into Kherozen's solution, as it may do exactly what you need.

---------------------------------------

In my limited experience, 80-90% of all problems brought to my attention can be attributed to PEBCAK...the other 10-20% can be attributed to MS!
 
Thank you.
In a moudle, I have:
Global strID As Long

First Form:
Private Sub ID_AfterUpdate()
strID = Me!ID
End Sub

Other forms:
Private Sub ID_Enter()
Me!ID = strID
End Sub
Also, in the property of ID: IME Sentence Mode = Phrase Predict

Now, when I enter data, the ID can be carried over. However, when I want to open the form to edit some record, I can only navigate on the first form, for the others, I can only see the last last entered record. Do you know how to fix this? Many thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top