Double Click A Record To Open In A Form

jesusoneez

IT Dogsbody
Local time
Today, 18:59
Joined
Jan 22, 2001
Messages
109
I have a few search forms that, when search parameters are entered, a continuous subform displays the results (summarised...not all fields show).

I want to be able to double click a field in any given record, and have it open in a form allowing editing of the record.

I know I need something in the OnDoubleClick event of the text box I want to double click, which would then open the form, but I don't know what code to use.

For the sake of argument, I want to double click on the txtSerialNumber text box to do it, as this is a unique field.

Thanks.
 
Hi
I have just pulled an example from one of my databases to give you an idea.
What I use is
Code:
Private Sub txtDrug_DblClick(Cancel As Integer)
On Error GoTo Err_txtDrug_DblClick
    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim strScrNo As String

    stDocName = "frmViewScrHisLab"
    stLinkCriteria = "[strScrNo]=" & "'" & Me.txtSerialNo & "'"
        DoCmd.OpenForm stDocName, , , stLinkCriteria
        DoCmd.MoveSize 500, 600, 14000, 7500

Exit_txtDrug_DblClick:
    stDocName = vbNullString
    stLinkCriteria = vbNullString
    Exit Sub

Err_txtDrug_DblClick:
    MsgBox Err.Description
    Resume Exit_txtDrug_DblClick
    
End Sub
Clearly you would have to adapt form names and the linking criteria
Hope this helps
 
Yup, I can see how that'd work. Thanks for your (very quick) help!

That's my problem half the time, I can see how coding works when I see it, I just don't know how to code...

I can read but I can't write. :)
 
Been there. Done the jigsaw.
Don't worry since the process never ends. I now struggle and puzzle over things that are a bit more complex, but can still remember struggling over that one a few years back. It is all part of the learning curve!
 
Thanks, Oldsoftboss. I think I'm going to go with Malcy's solution, but it's always nice to have several ways of doing the same thing.
 
Malcy, I plopped this code in this morning and it didn't work...took me an an hour to figure out what strScrNo was for, and that it wasn't relevant to me and needed changing!

Works a treat now I've put my own field name in!

Thanks again.
 
Glad it worked. I think the Dim for strScrNo was a bit of a red herring - sorry. Do not know how it cropped up!!
Anyway good luck
 

Users who are viewing this thread

Back
Top Bottom