Hi,
I'm new to the forums, there seems to be a nice helpful community here!
My question is in regards to opening a form in ReadOnly mode. I've been working on this for hours; hopefully there's an answer.
Basically I need to open the form while linking a hidden field to the form. This works fine in 'acFormAdd' mode, but does not work in 'acFormReadOnly' mode.
My code to open the form:
Code:
Private Sub cmdOpen_Click()
On Error GoTo addJump
Call openForm("frmProgress", "[ProjectID]=" & "'" & _
Form_frmProjectScreen![ProjectID] & "'", "Add")
Exit Sub
addJump:
Call addJumpRun
End Sub
Code:
Sub openForm(stDocName As String, Optional stLinkCriteria As String, _
Optional stType As String) ' Add, Read
Dim tmpStType As String
Select Case stType
Case "Add"
DoCmd.openForm stDocName, , , stLinkCriteria, acFormAdd
Case "Read"
DoCmd.openForm stDocName, , , stLinkCriteria, acFormReadOnly
Case Else
DoCmd.openForm stDocName, , , stLinkCriteria
End Select
End Sub
As you can see, the link criteria carries over the [ProjectID], which is a hidden field on both forms. If I change "Add" to "Read" when calling the OpenForm procedure, access gives me a 2501 runtime error saying the form can't open.
The query I use on the other form (that uses the [ProjectID]) looks like:
Code:
SELECT TOP 1 tblPhases.PhaseName, tblUpdates.UpdateDate, tblUpdates.ProjectID, tblUpdates.TopicID, tblUpdates.PhaseID FROM tblPhases INNER JOIN tblUpdates ON tblPhases.PhaseID=tblUpdates.PhaseID GROUP BY tblPhases.PhaseName, tblUpdates.UpdateDate, tblUpdates.ProjectID, tblUpdates.TopicID, tblUpdates.PhaseID HAVING (((tblUpdates.ProjectID)=Forms!frmProjectScreen!ProjectID) And ((tblUpdates.TopicID)=6)) ORDER BY tblUpdates.UpdateDate DESC;
I'm thinking it might be a form properties glitch or maybe SQL statement is somehow messing it up? I don't know. I know my vba calls for "Read" and "Add" are correct because I use the same call for multiple other related forms.
The situation would make more sense if both 'Add' and 'ReadOnly' didn't work.. but 'Add' works perfectly.
Thanks for your help