vbams-access-2016

Enter Parameter Value Dialog Box when opening form


I have a form open and I have set the ID number up as a hyperlink to another form. I have created the code below to open up however it now comes up with the Enter Parameter Value dialog box. When I put the ID number it opens correctly.

Private Sub StudentID_Click()
    Dim recordID As Integer
    recordID = Me.StudentID
    DoCmd.OpenForm "Students Extended", , , "Studentid=StudentNumber"
End Sub

Solution

  • I guess you are after something like this:

    Private Sub StudentID_Click()
    
        Dim recordID As Long
    
        recordID = Me.StudentID
        DoCmd.OpenForm "Students Extended", , , "Studentid = " & recordID & ""
    
    End Sub