|
-
Feb 13th, 2000, 07:40 AM
#1
Thread Starter
Dazed Member
Im not to sure how to code this. If i have two command buttons on a form,one to step foward and one to step back in a table built in access.
Private Sub Command_ bckClick()
Customers.Recordset.MovePrevious
End Sub.
What is the variable that i have to define? Dim ????? as ??????
Thanx....
-
Feb 13th, 2000, 09:29 AM
#2
Member
Hi,
first decalre the recordset object
Dim rst as recordset
set rst = new recordset
rst.open "some thing about your conncetion and all"
if you are moving previous
first check for BOF
if rst.BOF then
msgbox"This is the first record"
[OR disable the previous button]
else
rst.moveprevious
end if
if you are moving next
check for EOF
if rst.EOF then
msgbox
[or disable the next button]
else
rst.movenext
end if
If you are using datacontrol for this then you don't need to declare.
You can use datacontro1.recordset.moveprevious or movelast
But check BOF or EOF first
Thanks
karun
[This message has been edited by karunakaran (edited 02-13-2000).]
-
Feb 13th, 2000, 11:11 AM
#3
Thread Starter
Dazed Member
Thanks for the help. Youre a lifesaver.
Brandon.
-
Feb 13th, 2000, 11:43 AM
#4
Thread Starter
Dazed Member
One Quick Question. The coding has to be behind the foward and back command buttons.
So if i have
Prviate Sub cmdFoward_CLick()
If rs.EOF Then
MsgBox ("This is the last Record")
Else
rs.MoveNext
End If
End Sub
I get a runtime error '424'Object Required. Everything else is in the Form_Load event (Setting the rs and the db)
-
Feb 13th, 2000, 12:38 PM
#5
Fanatic Member
If you are using just Dim rs As RecordSet in Form_Load() event then it isn't detected anywhere else but in that event (something like that at least ). What you could do is to Dim it in (General) (Declarations) part of your code or use this in a Module: Public rs as Recordset. It should help
HTH
------------------
Visual Basic Programmer
------------------
PolComSoft
You will hear a lot about it.
-
Feb 13th, 2000, 12:39 PM
#6
New Member
Instead of putting it in the form_load put it into the form_activate.
I found that fixed it.
------------------
Tommy Boy.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|