How can I do this?

  • Thread starter Thread starter antonov
  • Start date Start date
A

antonov

Hello everybody, I have this report. When I double click on any of the
fields in this report I need the form Warehouse to open and to show the
record I've clicked on.... is it possible?
Thanks
 
Hi Antonov

Not really sure if it’s a good idea (or possible) to run the actions you
want from a report – I only use reports for viewing or printing – If it is
someone else will let you know.

Anyway, the basic function to open a form on double click would be to use
DoCmd.OpenForm. If used behind a form field it would look something like
this.

Private Sub SomeFieldName_DblClick(Cancel As Integer)
DoCmd.OpenForm "SomeFormName", acNormal, "", "", , acNormal
End Sub

Not that this would not filter the form as you want. To do this you need to
“inform†access which record you want the form to open at by applying a where
clause.

If you have a common field on both forms you can simply “link†them so that
the new form opens with “that†form’s data. Something like this (I have use
the standard mesg box if there is an error but you can change this if you
need to)

Of course you can select the specific data that you want to “link†if this
is the case you would need to specify this data as
stLinkCriteria = "[WhatEverFieldInNewForm]=" & Me![WhatEverNameOn1stForm]

So the whole thing would look something like this

Private Sub SomeFieldName_DblClick ()
On Error GoTo Err_ SomeFieldName_DblClick
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FormToOpen"
stLinkCriteria = "[FieldInNewForm]=" & Me![FieldOn1stForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ SomeFieldName_DblClick:
Exit Sub
Err_ SomeFieldName_DblClick:
MsgBox Err.Description
Resume Exit_ SomeFieldName_DblClick
End Sub


If you're not sure about coding then you could look at using a macro to get
the results you want.

Hope this helps
 
I have changed from report to form. I will try your suggestion and let you
know.... thank you very much
Wayne-I-M said:
Hi Antonov

Not really sure if it's a good idea (or possible) to run the actions you
want from a report - I only use reports for viewing or printing - If it is
someone else will let you know.

Anyway, the basic function to open a form on double click would be to use
DoCmd.OpenForm. If used behind a form field it would look something like
this.

Private Sub SomeFieldName_DblClick(Cancel As Integer)
DoCmd.OpenForm "SomeFormName", acNormal, "", "", , acNormal
End Sub

Not that this would not filter the form as you want. To do this you need
to
"inform" access which record you want the form to open at by applying a
where
clause.

If you have a common field on both forms you can simply "link" them so
that
the new form opens with "that" form's data. Something like this (I have
use
the standard mesg box if there is an error but you can change this if you
need to)

Of course you can select the specific data that you want to "link" if this
is the case you would need to specify this data as
stLinkCriteria = "[WhatEverFieldInNewForm]=" & Me![WhatEverNameOn1stForm]

So the whole thing would look something like this

Private Sub SomeFieldName_DblClick ()
On Error GoTo Err_ SomeFieldName_DblClick
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FormToOpen"
stLinkCriteria = "[FieldInNewForm]=" & Me![FieldOn1stForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ SomeFieldName_DblClick:
Exit Sub
Err_ SomeFieldName_DblClick:
MsgBox Err.Description
Resume Exit_ SomeFieldName_DblClick
End Sub


If you're not sure about coding then you could look at using a macro to
get
the results you want.

Hope this helps

--
Wayne
Manchester, England.
Enjoy whatever it is you do


antonov said:
Hello everybody, I have this report. When I double click on any of the
fields in this report I need the form Warehouse to open and to show the
record I've clicked on.... is it possible?
Thanks
 
Hello Wayne, I've copied your function and changed the names as you
suggested. When I doubleclick on the field (Dossier) a window appears in
which I am suppose to input something (I don't know what) and when I enter,
the form I need to open does open but not on the record I chose (Dossier -
also in this form)
In short: the form is called RECAP and the field I doubleclick on is called
Dossier
the form which should opne is called Warehouse and the linkfield is
Dossier....
This is how the function looks like now:

Private Sub Dossier_DblClick ()
On Error GoTo Err_ Dossier_DblClick
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Warehouse"
stLinkCriteria = "[Dossier]=" & Me![Dossier]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ Dossier_DblClick:
Exit Sub
Err_ Dossier_DblClick:
MsgBox Err.Description
Resume Exit_ Dossier_DblClick
End Sub

Thank you again for your help




Wayne-I-M said:
Hi Antonov

Not really sure if it's a good idea (or possible) to run the actions you
want from a report - I only use reports for viewing or printing - If it is
someone else will let you know.

Anyway, the basic function to open a form on double click would be to use
DoCmd.OpenForm. If used behind a form field it would look something like
this.

Private Sub SomeFieldName_DblClick(Cancel As Integer)
DoCmd.OpenForm "SomeFormName", acNormal, "", "", , acNormal
End Sub

Not that this would not filter the form as you want. To do this you need
to
"inform" access which record you want the form to open at by applying a
where
clause.

If you have a common field on both forms you can simply "link" them so
that
the new form opens with "that" form's data. Something like this (I have
use
the standard mesg box if there is an error but you can change this if you
need to)

Of course you can select the specific data that you want to "link" if this
is the case you would need to specify this data as
stLinkCriteria = "[WhatEverFieldInNewForm]=" & Me![WhatEverNameOn1stForm]

So the whole thing would look something like this

Private Sub SomeFieldName_DblClick ()
On Error GoTo Err_ SomeFieldName_DblClick
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FormToOpen"
stLinkCriteria = "[FieldInNewForm]=" & Me![FieldOn1stForm]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ SomeFieldName_DblClick:
Exit Sub
Err_ SomeFieldName_DblClick:
MsgBox Err.Description
Resume Exit_ SomeFieldName_DblClick
End Sub


If you're not sure about coding then you could look at using a macro to
get
the results you want.

Hope this helps

--
Wayne
Manchester, England.
Enjoy whatever it is you do


antonov said:
Hello everybody, I have this report. When I double click on any of the
fields in this report I need the form Warehouse to open and to show the
record I've clicked on.... is it possible?
Thanks
 
Back
Top