Opening 2nd form after selecting a record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I open a 2nd form after user selects a record on the 1st
form(datasheet view) The 2nd form contains more details Thanks for your help
 
Hi, Eddie.

You can't put a button on a form in datasheet view. One option is to
include a button on a Continuous Form, which can be made to look much like
datasheet view.

Or you could use another event, such as double-clicking on a field. The
following code opens a second form by clicking on the ID field, and filters
the second form by matching the ID field to the value of the current record
on the 1st form.

Private Sub ID_DblClick(Cancel As Integer)
On Error GoTo Err_ID_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "PUTYOUR FORMNAME HERE"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_ID_DblClick:
Exit Sub

Err_ID_DblClick:
MsgBox Err.Description
Resume Exit_ID_DblClick
End Sub

HTH
Sprinks
 
Good evening

The general statement would be as follows. Simply replace frmDetails with your
form name as well as the RecordID with the proper ID


DoCmd.OpenForm "frmDetails", _
WhereCondition:="RecordID=" & Me.RecordID


Best Regards

Maurice St-Cyr
Micro Systems Consultants, Inc.
 
I would like to use the information from this original email to open a
Report(rather then a Form) from a Form after selecting record.

The coding works if I create a Form named "Label" but I cannot figure out
how to specify and open a Report named "Label".

I have attached the VB code I'm using for your review. First I save the
selected record and then I would like to open the report named "Label".

Private Sub Save_Click()
On Error GoTo Err_Save_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Label"

stLinkCriteria = "[Key]=" & Me![Key]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Save_Click:
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click
End Sub

Sorry but I am brand new at using VB coding in Access.

Thanks so much for any help,

NikkiB
 
Figured it out.

Had to change:
stDocName = "Label"

stLinkCriteria = "[Key]=" & Me![Key]
DoCmd.OpenForm stDocName, , , stLinkCriteria

To:
stDocName = "Label"

stLinkCriteria = "[Key]=" & Me![Key]
DoCmd.OpenReport stDocName, , , stLinkCriteria

But this just automatically printed the report so I further changed the
coding to open the report in print preview allowing the user to review the
information. Here was the final coding I used.

stDocName = "Label"

stLinkCriteria = "[Key]=" & Me![Key]
DoCmd.OpenReport stDocName, acPreview , , stLinkCriteria

NikkiB said:
I would like to use the information from this original email to open a
Report(rather then a Form) from a Form after selecting record.

The coding works if I create a Form named "Label" but I cannot figure out
how to specify and open a Report named "Label".

I have attached the VB code I'm using for your review. First I save the
selected record and then I would like to open the report named "Label".

Private Sub Save_Click()
On Error GoTo Err_Save_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Label"

stLinkCriteria = "[Key]=" & Me![Key]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Save_Click:
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click
End Sub

Sorry but I am brand new at using VB coding in Access.

Thanks so much for any help,

NikkiB

EddieZ said:
How do I open a 2nd form after user selects a record on the 1st
form(datasheet view) The 2nd form contains more details Thanks for your help
 
Back
Top