not sure how to open form at particular record

pb21

Registered User.
Local time
Today, 09:59
Joined
Nov 2, 2004
Messages
122
My form is opened with an on click event:

DoCmd.OpenForm "FrmEnhancedEnrolment", , , , acFormEdit
MyValue = InputBox(Message, Title, Default, 100, 100)

The msgbox then gets the value of the record I wish to find(at present the form is at the next new number despite opening on edit)

I am not sure what method to use to get it to open at the selected myValue.

I am searching on studId PK so I guess I have to convert the string from input box to a long.

help would be much appreciated.

I tried this also:
DoCmd.OpenForm "FrmEnhancedEnrolment", , , "[studentid]='myvalue'", acFormEdit

but it reports docmd action cancelled.

regards
 
Last edited:
try this:

DoCmd.OpenForm "FrmEnhancedEnrolment" , , , "[studentid]=" & myValue
 
filtered but with no record

I tried your suggestion and it worked a treat coding wise but filtered with no record showing. i took off the filtering and navigated to the record i wanted to prove it was there. Not sure what to do now?

here is the function that opened the form:

Function OpenFormWithInput()
Dim Msg As String
Dim Title As String
Dim Defvalue As String
Dim Answer As String
Dim stid As Long

Msg = "Enter a Student ID."
Title = "OPEN FORM"
Defvalue = ""
Answer = CInt(InputBox(Msg, Title, Defvalue))
If Answer <> "" Then
StudID = CLng(Answer)

DoCmd.OpenForm "FrmEnhancedEnrolmentedit", , , "[studentid]=" & StudID
Else
' DoCmd.OpenForm "Customers"
End If
End Function


studentid is an autonumber in the student table hence the conversion of answer to long.
 
all working now:

DoCmd.OpenForm "FrmEnhancedEnrolmentedit", , , "[StudentID]= " & Studid, acFormEdit

Kind regards for forum help.
 

Users who are viewing this thread

Back
Top Bottom