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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Object doesn't support this property or method" message 2

Status
Not open for further replies.

TeresePamela

Programmer
Sep 4, 2003
40
US

When running the code below as the on-click event of a button on a form, I receive the error message "Object doesn't support this property or method" when it gets to the line:
If vartype = "SPECIAL" Then
Can anyone tell me what I've done wrong?

I really, really appreciate all the help you guys are giving me.

Thanks
Pam

Private Sub SetFee_Click()

Dim dtExt1 As Date
Dim dtExt2 As Date
Dim dtExt3 As Date
Dim dtExt4 As Date
Dim dtExt5 As Date
Dim dtFeeDue As Date
Dim nmMonth As Integer
Dim vartype As String

Set Select1 = CurrentDb.OpenRecordset("Accounts")
Select1.MoveFirst
While Not Select1.EOF()

If IsNull(Select1.PYMT_RCVD) And Select1.Fee_Flag = "Y" Then
If vartype = "SPECIAL" Then
dtFeeDue = DateAdd("m", 3, Select1.DEADLINE)
Else
dtFeeDue = Select1.DUE_DATE
End If
dtExt1 = DateAdd("m", 1, dtFeeDue)
dtExt2 = DateAdd("m", 2, dtFeeDue)
dtExt3 = DateAdd("m", 3, dtFeeDue)
dtExt4 = DateAdd("m", 4, dtFeeDue)
dtExt5 = DateAdd("m", 5, dtFeeDue)

If Date > dtFeeDue And Date <= dtExt1 Then
nmMonth = 1
End If
If Date > dtExt1 And Date <= dtExt2 Then
nmMonth = 2
End If
If Date > dtExt2 And Date <= dtExt3 Then
nmMonth = 3
End If
If Date > dtExt3 And Date <= dtExt4 Then
nmMonth = 4
End If
If Date > dtExt4 And Date <= dtExt5 Then
nmMonth = 5
End If

Select1.Edit
Select1.EXT_MTHS = nmMonth
Select1.Update
End If
Select1.MoveNext
Wend
Beep
MsgBox "Procedure has Finished"

End Sub
 
vartype is a function as in var1 = VARTYPE(var2). Try changing your variable name to something that cannot be confused with a VB reserved name.
 
In addition to Dimandja's comment, I notice that you are using the variable prior to assigning it a value.

IE Dime Vartype as string, immediately after, if vartype = blah, Actally, I don't see anywhere in your code any assignment of value to the variable.

ChaZ


Ascii dumb question, get a dumb Ansi
 
Glad you watching out Blorf.

Actually my intent was to declare the variable, then after reading the record move the value of the field into it and then test the variable. Now I see that's redundant, I should have simply said:
If select1.fieldname = "SPECIAL" Then
right?

But.. if I had wanted to use the variable name would it have been:
If strtype = "SPECIAL" Then
or is that incorrect syntax?

Thanks a lot
Pam
 
The syntax is good, so long as you place sele1.fieldname into the variable first. Either way works. Less code the easier to debug though. Unless you are using more code for speed.

ChaZ

Ascii dumb question, get a dumb Ansi
 
Ah, now it's starting to feel familiar. So if I declared:
Dim StrType = select1.fieldname and then simply tested StrType = etc. I'd be in good shape -don't need quotes or brackets around anything?

At this point the easier to debug the better. I have some things I want to work on, but have (as you can tell) not gotten all the basics of this down yet. Having trouble being patient, but the speed that you guys are giving my answers is incredible. I have been telling all my co-workers how great you guys are :)

Seriously Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top