Affichage des articles dont le libellé est Open a record from Listbox in another form. Afficher tous les articles
Affichage des articles dont le libellé est Open a record from Listbox in another form. Afficher tous les articles

Open a record from Listbox in another form

jeudi 23 avril 2015

Hello,
I hope this is the right place to ask for help.
I'm not sure how to write the code since docmd.GoToRecord is not a line I'm overly familiar with.

I have a form where, by clicking a button, I jump to another form with a searching bar through a listbox. Now, when I double click a record in the list, I'd like to have the previous form go to that record and the current form to close. I'd like to avoid reopening the previous form since - upon loading - it runs a code that alters a table.
Also, I tried (but I have no idea how to accomplish this) to get this effect: whenever I click elsewhere from the current searching form, I'd like it to close down. At the moment if I click out of the window of this popup form it blinks several times to accentuate the fact that I must close it by clicking on the 'X'.

Here are my attempts
on the main form:
Code:

Private Sub SearchClient_Click()
      DoCmd.OpenForm "Risultati", , , , , acDialog
End Sub

On the 'popup' search form
Code:


Private Sub SearchResults_DblClick(Cancel As Integer)
        DoCmd.GoToRecord '?? I'm not sure how to write it
End Sub

Private Sub Form_LostFocus()
        DoCmd.Close acForm, frmMe.Name 'doesn't work :(
End Sub

'the following part was something I found online
Private Sub Form_Open(Cancel As Integer)
        Dim frmPrevious As Form
        Set frmPrevious = Screen.ActiveForm
End Sub
   
Private Sub Form_Close()
          frmPrevious.SetFocus
End Sub

Open a record from Listbox in another form

Labels