By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,203 Members | 1,383 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,203 IT Pros & Developers. It's quick & easy.

Creating an AttachEvent to send msgbox

P: n/a
Hi,

I am working with a Microsoft Data Page where the records are filtered
by two dates the user selects prior to any records being loaded. After
selecting dates they click on a button (BtnGo) to fire the filter
event. Currently if no records are found that match criteria, the page
just stays empty. I would like the user to receive a message if no
records were found for the dates provided. I spent a lot of time
attempting to add a clause to my IF...Then statement but finally
figured out that logically it wouldn't work.

What I'm attempting to do now is use "AttachEvent" with my
"onclick" event to send a message if a sum field is empty after the
records are filtered (which would be the case if no records were
found). I've cobbled together code for an AttachEvent based on what
I've found on the internet; although without any clear directions,
I'm not sure if I've even remotely written it correctly. As
currently written, I receive an error message when I open the page that
an object is required. I've tried both "BtnGo" and "onclick"
as my object and received the same error message for both.

I would certainly appreciate any suggestions for correcting my code or
a head's up that AttachEvent won't work.

<SCRIPT language=vbscript>

Sub OnFilterComboChange()
Dim stWhere
'Don't do anything unless user selects a value from each list box.
If (FromMondayDate.value <"" and ToSundayDate.value <"") Then
stWhere = "CrewTime.CrewDate>=" & "#" & FromMondayDate.value & "#" &
" "
stWhere = stWhere & "AND CrewTime.CrewDate<=" & "#" &
ToSundayDate.value & "#"
stWhere = stWhere & "AND CrewTime.DataCollectorHours<>" & " 0.0"

'Set the server filter on the CrewTime Recordset.
MSODSC.RecordsetDefs.Item("CrewTime Other Hours Query").ServerFilter
= stWhere
End If
End Sub
</SCRIPT>

<SCRIPT language=vbscript event=onclick for=Btngo>
<!--
OnFilterComboChange()
-->
</SCRIPT>
<SCRIPT language=vbscript>
<!--
dim Check
set Check = getRef("CheckTotal")
Btngo.attachCheckTotal Check

Sub CheckTotal()
If OtherHours0.value = "" Then
msgbox "No records for dates provided."
End if
End sub
-->
</SCRIPT>

Jul 25 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Have you read
http://msdn.microsoft.com/workshop/a...ttachevent.asp
?

I suppose that because Data Access Pages are htm files which run only
in Internet Explorer that one can use IE DHTML methods and properties
in them but I would never have guessed that anyone was actually doing
so. I had thought IE's proprietary methods became pretty much unused
when Firefox and other Browsers started to take a share of the market.
Well, I was wrong.

The page may give you some help. I'll be interested to see who responds
and indicates he/she has some experience doing this. Good Luck!

Jul 25 '06 #2

P: n/a
Thanks for your response.

I've read the article plus whatever else I could find regarding
AttachEvent & VBScript. I don't know that I can use AttachEvent - that
is part of my issue. I'm a novice at code and am learning as I go - so
far its been a pretty steep learning curve. I'm just hoping that
someone can point me in the right direction if I'm way off the base.

Lyle Fairfield wrote:
Have you read
http://msdn.microsoft.com/workshop/a...ttachevent.asp
?

I suppose that because Data Access Pages are htm files which run only
in Internet Explorer that one can use IE DHTML methods and properties
in them but I would never have guessed that anyone was actually doing
so. I had thought IE's proprietary methods became pretty much unused
when Firefox and other Browsers started to take a share of the market.
Well, I was wrong.

The page may give you some help. I'll be interested to see who responds
and indicates he/she has some experience doing this. Good Luck!
Jul 25 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.