-----Original Message-----
Thanks a lot. Now, rst is fine.
But, ii = txtTextbox1 * txtTextbox2 is not working. The
mistake is "Run-time error '2447'. There is an invalid use
of the .(dot) or ! operator or invalid parentheses."
I think the problem is that I'm getting textbox1 from
cboBox1.Column(1). In the Form Control source for
txtTextbox1 is =cboBox1.Column(1).
Then, I tried ii = Me.[cboBox1].Column(1) * Me.txtTextbox2.
There is no any error message but iii = iii + ii
and .MoveNext doesn't change the values and ii is always
the same.
Then, I tried to add
DoCmd.GoToRecord acDataForm, strFormName, acNext
The values are changed and calculation is correct. But, I
have a problem with .EOF.
It doesn't know when it reaches the end of the records and
on the last record I have a mistake.
Could you advise how to handle with it.
Thanks
-----Original Message-----
Doing the following I'm getting a type mismatch mistake.
Private Sub Form_Current()
Dim ii As Long, iii As Long
Dim rst As Recordset
ii = 0
iii = 0
Set rst = Me.RecordsetClone ' here is a mistake
'Run time error '13'. Type mismatch
'Clone form's recordset
With rst
.MoveLast
.MoveFirst
Do Until .EOF
ii = [txtTextBox1] * [txtTextBox2]
iii = iii + ii
.MoveNext
Loop
End With
rst.Close
End Sub
Can anybody advise what's wrong there.
Thanks
If you are using Access 2000 or Access 2002, you probably need to
add a reference to DAO (the Microsoft DAO 3.6 Object Library). That
reference is added from the VB Editor environment, by clicking Tools
-> References..., locating the reference in the list, and putting a
check mark next to it.
Then, if you are using Access 2000, 2002, or 2003, make sure Access
knows that it's a DAO recordset you are declaring, not the
(incompatible) ADO version of the Recordset object, by modifying your
Dim statement as follows:
Dim rst As DAO.Recordset
Incidentally, your call to the recordset's .MoveLast method serves no
purpose that I can see.
Your error now comes from the fact that you aren't qualifying the field
names with the recordset object. That presupposes that "txtTextbox1"
and "txtTextbox2" are the names of fields in the form's recordset. If
that is the case, you would have to change this:
ii = [txtTextBox1] * [txtTextBox2]
to this:
ii = ![txtTextBox1] * ![txtTextBox2]
Also, remove this line altogether:
You didn't open this recordset, so you shouldn't close it.
I assume that you have some code in that routine that you haven't shown
me, because otherwise you're performing that calculation and never doing
anything with the result. If you don't get what you want out of the
corrected procedure, you'd better explain what it is you're trying to
do. As it stands, I don't see any reason for you to be using
DoCmd.GoToRecord acDataForm, strFormName, acNext
, since you're navigating through the form's recordsetclone using
rst.MoveNext.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
.