Opening Form and Passing Variables (1 Viewer)

q582gmzhi

Registered User.
Local time
Today, 04:30
Joined
Dec 23, 2002
Messages
48
Hi,

I need some advice for the best way to proceed with some code.

I use the following to update a form and then it opens a new form which asks for the following information:
GameID (on main form)
Batsman No (on main form)
Batsman Score (on main form)
Overs (on main form)
Wkt (on main form)
Total (on main form)
Dismissed By (on main form)
Dismissal Type (user selects)

When I open the form "frmDismissals"
I can get the fields default value to populate the field using: =[Forms]![frmGames]![tDate] etc

However, if I open the form and use the above it will need to know whether it looks at the left or right batsman?

Can I pass the info via some variable to the form so that when it opens so it populates the fields. This way I can use the same form for both batsman.

Or is there another way to do it?


Code:
Dim tLastMan, tLastWkt As Integer
If MsgBox("Do you wish to dismiss this Batsman?", vbQuestion + vbYesNo + vbDefaultButton2, "Dismiss Batsman") = vbNo Then
Exit Sub
Else
'updates lastman score
Me.tLastMan.Value = tLeftBatScore.Value
'updates last wkt score
Me.tLastWkt.Value = tTotal
'resets leftbatsmans score and number ready for next batsman
Me.tLeftBatScore.Value = 0
Me.tLeftBatNo.Value = 0
'increments the wkts
Me.tWkts.Value = Me.tWkts.Value + 1

'opens form for dismissal information
    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmDismissals"
    
    stLinkCriteria = "[tGameID]=" & Me![tID]
    DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

Thanks in advance

Darrell.....
 
Last edited by a moderator:

Tim L

Registered User.
Local time
Today, 04:30
Joined
Sep 6, 2002
Messages
414
q582gmzhi said:
When I open the form "frmDismissals"
I can get the fields default value to populate the field using: =[Forms]![frmGames]![tDate] etc

However, if I open the form and use the above it will need to know whether it looks at the left or right batsman?

Can I pass the info via some variable to the form so that when it opens so it populates the fields. This way I can use the same form for both batsman.

Or is there another way to do it?

You could load the values into variables in VBA, open the new form and then populate the required fields?

Tim
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 04:30
Joined
Jul 9, 2003
Messages
16,282
q582gmzhi said:
If I open the form and use the above it will need to know whether it looks at the left or right batsman?


I am not sure what you mean by the above? I think the attached example may offer a solution.
 

Attachments

  • OpenAfromBTransferInfo.zip
    50.9 KB · Views: 1,377

q582gmzhi

Registered User.
Local time
Today, 04:30
Joined
Dec 23, 2002
Messages
48
Hi Uncle Gizmo,

Thanks for the demo, that works great.

Daz....
 

Users who are viewing this thread

Top Bottom