Object dosent support this property or method

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This code behind a command button should check to see if a record exists and
open a form with that data if it does. If record does not exist it will open
the form in data entry mode.

I don't understand this error???


Private Sub cmdMember_Click()
On Error GoTo Err_cmdMember_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim dbcurrent As DAO.Database
Dim rstemp As DAO.Recordset

If IsNull([cmdMember]) Then
MsgBox "Please enter a Member # before proceeding."
Exit Sub
Else
'Check to see if a record already exists
Set dbcurrent = CurrentDb
Set rstemp = CurrentDb.OpenRecordset("select * from [tblMemberInfo]
where [MemberNo] = " & "'" & Me.[cmdMember] & "'" & ";")
stDocName = "f_MemberSub"

If rstemp.RecordCount > 0 Then 'Open Record
stLinkCriteria = "[MemberNo]=" & "'" & Me.[cmdMember] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else 'Create a new record
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms!f_MemberSub.DataEntry = True
End If
Forms!f_MemberSub.MemberNo = Me.cmdMember
End If

Exit_cmdMember_Click:
Exit Sub

Err_cmdMember_Click:
MsgBox Err.Description
Resume Exit_cmdMember_Click

End Sub
 
Assuming that MemberNo is the name of a control on the form, try

Forms!f_MemberSub!MemberNo

If that still doesn't work, try renaming the control (but don't change its
ControlSource!)
 
Thanks
I renamed the control and noticed it was wrong in another area.

It's working now!!!



Douglas J. Steele said:
Assuming that MemberNo is the name of a control on the form, try

Forms!f_MemberSub!MemberNo

If that still doesn't work, try renaming the control (but don't change its
ControlSource!)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Dan @BCBS said:
This code behind a command button should check to see if a record exists
and
open a form with that data if it does. If record does not exist it will
open
the form in data entry mode.

I don't understand this error???


Private Sub cmdMember_Click()
On Error GoTo Err_cmdMember_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim dbcurrent As DAO.Database
Dim rstemp As DAO.Recordset

If IsNull([cmdMember]) Then
MsgBox "Please enter a Member # before proceeding."
Exit Sub
Else
'Check to see if a record already exists
Set dbcurrent = CurrentDb
Set rstemp = CurrentDb.OpenRecordset("select * from [tblMemberInfo]
where [MemberNo] = " & "'" & Me.[cmdMember] & "'" & ";")
stDocName = "f_MemberSub"

If rstemp.RecordCount > 0 Then 'Open Record
stLinkCriteria = "[MemberNo]=" & "'" & Me.[cmdMember] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else 'Create a new record
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms!f_MemberSub.DataEntry = True
End If
Forms!f_MemberSub.MemberNo = Me.cmdMember
End If

Exit_cmdMember_Click:
Exit Sub

Err_cmdMember_Click:
MsgBox Err.Description
Resume Exit_cmdMember_Click

End Sub
 
Back
Top