Object dosent support this property or method

D

Dan @BCBS

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
 
D

Douglas J. Steele

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!)
 
D

Dan @BCBS

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
 

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

Similar Threads

User Defined 3
Type Mismatch 3
Working outlook via vba code with xlsx - error 0
If Statements 4
Criteria when opening form 1
Type Mismatch 2
Type Mismatch 2
I am not "getting" it.....DoCmd. OpenForm 4

Top