docmd.openform, form only works once

S

Sassyx

Experiencing odd behaviour in Access 2002. When clicking the form to
retrieve detailed data, it only works once. Once I close the form opened as
below and double click again I am presented with a blank page, I have to
close Access and restart and still only works once. Thought maybe a focus
problem, but not a coder and need some guidance. Thank you in advance.

Private Sub Rank_DblClick(Cancel As Integer)



Dim DocName As String

Dim LinkCriteria As String



DocName = "FrmInfotab- Project Edit Form"

LinkCriteria = "[infoid] = Forms![FrmIa- Detail Info by ID]![infoid]"

DoCmd.OpenForm DocName, , , LinkCriteria



Exit_Project_DblClick:

Exit Sub
 
A

Allen Browne

Try:
1. Closing the form if it is already open. Otherwise the WhereCondition will
not work as expected, and the form won't receive focus.

2. Concatenating the ID value into the LinkCriteria.

Private Sub Rank_DblClick(Cancel As Integer)
Dim DocName As String
Dim LinkCriteria As String

DocName = "FrmInfotab- Project Edit Form"

If CurrentProject.AllForms(DocName).IsLoaded Then
DoCmd.Close acForm, DocName
End If

LinkCriteria = "[infoid] = " & Forms![FrmIa- Detail Info by ID]![infoid]
DoCmd.OpenForm DocName, , , LinkCriteria
....


This assumes that idfoid is a field of type Number, and that it has a value
(e.g. not at a new record).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top