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

Javascript intigrated into a Microsoft Access data page...help please

Status
Not open for further replies.

Jakobud

Technical User
Mar 9, 2001
51
US
I used Microsoft Access to create what is called a Data Access Page. It's basically a html page with code in it that makes it work with a Access Database. Anyways, I created a simple button on this page that, when pressed, changes all the controls on the page to display the information for what ever the next record is in the database. It's a 'next' button, essentially. Anyways, when I look at the code for what was generated, it looks like a mix between HTML, Javascript and Visual Basic. Here is the code of the button:

<BUTTON id=Command0
style=&quot;BACKGROUND-IMAGE: url(./Navigation_files/image001.bmp); BACKGROUND-POSITION: center center; BACKGROUND-REPEAT: no-repeat; HEIGHT: 0.396in; LEFT: 4.542in; POSITION: absolute; TOP: 0.458in; WIDTH: 0.396in&quot;
tabIndex=10 title=Command0></BUTTON>
<SCRIPT event=onclick for=Command0 language=javascript>
try { MSODSC.CurrentSection.DataPage.MoveNext (); }
catch (e)
{ alert (e.description);}
</SCRIPT>

It appears to use Javascript to actually change all the controls on the page to the next record. Anyways, what I want to do is make the button jump to the next 10 records, instead of just one. So if I'm currently on record 23, pressing the button would make me be on record 33. Get it? I was thinking that there must be some sort of offset I can apply to the above code so that if moves by a certain offset, but I don't know Javascript...can anyone please help me here? And be very specific please, as I am new to Access and Javascript. I already posted this in Access forums and I was told to try posting it here also. Thanks!

jake
 
See that place where it says .movenext() -- ???

Well, you could change the code there to make it say

.move(10);

I'm not sure if I would go monkeying around with it, though. Machine generated code is often EXTREMELY fragile, and you are likely to leave something out, or not think of some situational contingency that will produce an error.

One such contingency would be where if there weren't ten more records in the recordset... like say there were only two. This would produce an error.

To get around the above mentioned, you would need to implement some sort of checking mechanism to see if, in fact, there were ten more in the recordset...

I think you see my point. Do you know where to put that in? I certainly don't. And I'm sure that's not the only thing that might go wrong.

That machine generated code will, in all likelihood, work perfectly if left alone. But, if you go tinkering with it, then it will, in all likelihood, crash and burn and make you look bad in front of your users.

I would suggest looking at sites such as or in order to learn ASP so that you can write your own database access scripts. It really isn't that difficult (although I know looking at that code you posted appears daunting, ppl written code is much more readable).

Anyways, there's my two cents! **kachink**

good luck!:)
Paul Prewett
 
jake,


<SCRIPT event=onclick for=Command0 language=javascript>
try { MSODSC.CurrentSection.DataPage.MoveNext (); }
catch (e)
{ alert (e.description);}
</SCRIPT>


The variable MSODSC is of 'unknown' type to us since its declaration was not included in your post. I have no idea what it is.

What is obvious is that it has an object of also 'unknown' type named CurrentSection which in turn has an object of 'unknown' type named DataPage. The DataPage object contains the method MoveNext and may in fact be an ADODB.Recordset object.

In any case that object may contain other methods that could be used to accomplish your goal. For instance, the ADODB.Recorset object contains a Move method which takes, as it's first parameter, a number indicating the rows to move forward in the row set.

Good luck
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top