Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Two pieces of almost identical code, one works, one does not,

Status
Not open for further replies.

hmstoo44dd

Programmer
Sep 27, 2002
32
US
I have a form with a continuous subform. When I open the form with the first code example the subform gets the error, 'you can't assign a value to this object' when trying to edit a field.

The other code example works fine.

Both open the form to the correct records.

The openform event =
strFilter = "SessionKey = " & OpenArgs
DoCmd.ApplyFilter , strFilter

The only thing unusual about the subform is that I'm using .absoluteposition to number the subform records.

Anyone have any ideas?


*********************************************************
Private Sub cmdDatePicker3_Exit(Cancel As Integer)
On Error GoTo ErrHandler

Dim stDocName As String
Dim intSession As Integer

intSession = Me![SessionKey]

DoCmd.Hourglass True

stDocName = "frmUpdatePaperTimes"
DoCmd.OpenForm stDocName, , , , , , intSession

DoCmd.Hourglass False

Me.Visible = False
Exit Sub

ErrHandler:

*******************************************************
Sub View_Form_Click()
On Error GoTo Err_View_Form_Click

Dim stDocName As String
Dim intSession As Integer

If Nz(Me!cboSession) = "" Then
Exit Sub
End If

intSession = Nz(Me!cboSession.Column(4))

stDocName = "frmUpdatePaperTimes"
DoCmd.OpenForm stDocName, , , , , , intSession

Me![cboSession] = ""
Me.Visible = False

Exit_View_Form_Click:
Exit Sub

Err_View_Form_Click:
 
I found the answer. In the first piece of code the form is opened from another form that is dirty. All I needed to do was add 'DoCmd.RunCommand acCmdSaveRecord'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top