Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

data1.recordset.movenext & moveprevious

guy,

I am using a touchscreen with 2 images (up and down arrows) to move throw a data1 database.

My problem is when I get the begin or the end of the file it still trys to move the recordset and I get a error.

How can I disable image1 (up arrown) when the database reaches or is at the first record also when it reaces the last record (for the down image)

Thanks for any help I hope i explain this correct.

Drew
[457 byte] By [Drew_gable] at [2007-11-11 8:47:13]
# 1 Re: data1.recordset.movenext & moveprevious
It has been a little while since I've used VB6 (actually a long while) but here goes nothing.

The last record can be checked using the EOF property and then the image can be disabled if it is (e.g. if RS.EOF = true then imagedown.enabled = false)

As for the first record I'm unsure whethere this is actually valid syntaxing or if I made this property up but I'm sure it had BOF which can be used the same as EOF (e.g. if RS.BOF = true then imageup.enabled = false)

Hope this helps
xnemsis at 2007-11-11 17:24:59 >
# 2 Re: data1.recordset.movenext & moveprevious
Well that is the code I am using at the moment but it trys to go pass the last and first records in the database.

any thoughts guys & gals?

Drew
Drew_gable at 2007-11-11 17:25:59 >
# 3 Re: data1.recordset.movenext & moveprevious
Ok racking my brains and it's extremely hard as .net extremely different.

Is there not a count and selectedcell (or selectedindex) property? I seem to recall one in which case, check the selected doesn't equal the count.

Hope this is helpful and correct? :)
xnemsis at 2007-11-11 17:27:06 >
# 4 Re: data1.recordset.movenext & moveprevious
Could you post your code? I'm assuming that you are checking for BOF and EOF after MovePrevious/Next respectively?
pclement at 2007-11-11 17:28:11 >
# 5 Re: data1.recordset.movenext & moveprevious
well the code is
' image 1 ( backward arrow)
if data1.recordset.BOF = TRUE THEN
image1.enabled = false
else
data1.recordset.moveprevious
end if

' image 2 (forward arrow)
if data1.recordset.EOF = TRUE THEN
image2.enabled = false
else
data1.recordset.movenext
end if

but it keeps trying to go beond the eof and bof not sure why
Drew_gable at 2007-11-11 17:29:10 >
# 6 Re: data1.recordset.movenext & moveprevious
Could you also please post your code that connects / opens the database. As this is most likely the cause.
xnemsis at 2007-11-11 17:30:09 >
# 7 Re: data1.recordset.movenext & moveprevious
Sure that is

Data1.databaseName = App.path & "\products.mdb"
Data1.Refresh

The database is LOCAL ONLY no other conection is active on it
Drew_gable at 2007-11-11 17:31:04 >
# 8 Re: data1.recordset.movenext & moveprevious
When does the code you posted execute?
pclement at 2007-11-11 17:32:07 >
# 9 Re: data1.recordset.movenext & moveprevious
When the form activates

Sorry I fogot to mention that
Drew_gable at 2007-11-11 17:33:15 >
# 10 Re: data1.recordset.movenext & moveprevious
Are you sure you want to use the Activate event? Shouldn't the code execute after clicking (pressing) on the Image controls?
pclement at 2007-11-11 17:34:16 >
# 11 Re: data1.recordset.movenext & moveprevious
Also, this is perhaps more addressed at paul, but should the database not be initialised via a method such as open as oppose to refresh?
I can't recall if I've ever accessed a local DB so I'm unsure how to open one. But I know that the opening method and arguements passed affect how EOF and BOF return, e.g. adlockreadonly doesn't like to return EOF, etc.

Is this perhaps the cause? :)
xnemsis at 2007-11-11 17:35:14 >
# 12 Re: data1.recordset.movenext & moveprevious
it opens the database when the form displays

and then when you touch the arrow (mouse up settings) that is then when the code runs
Drew_gable at 2007-11-11 17:36:12 >
# 13 Re: data1.recordset.movenext & moveprevious
Also, this is perhaps more addressed at paul, but should the database not be initialised via a method such as open as oppose to refresh?

He's using a Data Control which means he has a persistent connection to the database.
pclement at 2007-11-11 17:37:15 >