Open Form From Continous View Form

rnutts

Registered User.
Local time
Today, 22:54
Joined
Jun 26, 2007
Messages
110
Hi

I have a form (frmenquirysearch) dwhich displays a summary of all the records in tblenquiry in continous view.
I want to open up frmenquiry which is a detailed view of the records using a command button on frmenquirysearch. I used the command button wizard and it has given me the code below. However when clicked the frmenquiry opens but at the first record not at the record I selected on the frmenquirysearch
Any thoughts as to why??

On Error GoTo Err_cmdViewDets_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmenquiry"
stLinkCriteria = "[enqref]=" & Me.[enqref]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdViewDets_Click:
Exit Sub
Err_cmdViewDets_Click:
MsgBox Err.Description
Resume Exit_cmdViewDets_Click


Many thanks

Richard
 
If [enqref] is a string then you will need quotes:
stLinkCriteria = "[enqref]='" & Me.[enqref] & "'"
 
Enqref is a numeric field

Have put in your suggestion and now I get the error message

Open Form Action is cancelled

the debug takes me to the line

DoCmd.OpenForm stDocName, , , stLinkCriteria


any more thoughts??
 
I have now taken out the ' from your first suggestion and the thing is now working

Women and computers can never be understood truly by man

Thanks for your help

Richard
 
Have worked out that the reason it started working was that I already had frmenquiry open and that when the cmd button is clicked on frmenquirysearch it takes me to the correct record. When frmenquiry is closed and the button is clicked, frmenquiry is opened but only at the first record!!!!!
 

Users who are viewing this thread

Back
Top Bottom