Running a query/macro with a Data Access Page

D

Drew

Is there a simple way to run a macro/query from a Data Access Page. I am not
a programmer, so the simplest method would be preferred.

Thanks,
 
A

Aaron Kempf

I'm dead serious

most of the trendy dorks in America are scared to be seen as a geek

learn programming or use pen and paper
 
A

Aaron Kempf

at least I'm not stuck being a Jr Programmer

you're a MDB script kid

i mean.. WOW I thought that we left all you kids in the 90s
 
D

Drew

I didn't mean to start a feud, but can either of you answer the original
question. Is there anything that I can do to run a macro from a DAP?
 
A

Aaron Kempf

a macro or a module?

yeah-- you can respond to VBA events-- you can do anythign you want in a web
browser


what did you have in mind.. run a couple of action queries?
 
A

Aaron Kempf

and for the record, this feud is because Microsoft is a drunken driver,
driving in the middle of the night without headlights

and then when someone asks serious questions-- they get hit by a concerted
FUD effort

re:DAP

I did find a really really sharp download from MIcrosoft.. I think that it
might have been called the Office XP Office Web Components Sample Pack or
something along those lines

I love DAP.
I love ADP.

I have used Office Web Components more then I'd like to admit... DAP totally
rock
 
A

Aaron Kempf

I just think that you'll have to do _SOME_ vba coding in order to apply
filters, run SQL; etc

I did extensive DAPs over the years

one thing that I found the most interesting.. was programmatically creating
DAPs... the hard way.. so I was using the webserver to do a bunch of stuff
in the background.. but then a day or so into this; I realized it would be
easier to just hit the DSC directly

<%

'-----------------------------------------------------

Sub writeDap(DAPID)

Dim rstDap

Set rstDap = Server.createobject("ADODB.Recordset")

rstDap.ActiveConnection = Session("cnn")

rstDap.Source = "select * FROM OR_DAP WHERE DAPID = " & DAPID

rstDap.Open


If rstDap.EOF = True Then

writePretty "<BR>Unknown DAPID :" & DAPID & ""

response.end

End If

Dim BaseTable

Dim DapTitle

Dim AltUrl

BaseTable = rstDap.fields("BASETABLE").value

DapTitle = rstDap.fields("NAME").value

AltUrl = rstDap.fields("ALTURL").value

Select case Len(AltUrl)

Case 0

response.write "<!-- DAPID " & DAPID & " AltUrl Length 0-->"

Case Else

response.write "<!--Dap Generated by AltUrl: " & ALTURL & "-->"

Call writeTitle(DAPID, DAPTITLE)

Call WriteUrl(Server.MapPath(AltUrl))

exit sub

End Select

'get all fields from base table

Dim rstVerifyTable

Set rstVerifyTable= Server.createobject("ADODB.Recordset")

rstVerifyTable.ActiveConnection = Session("cnn")

rstVerifyTable.Source = "select TOP 1 * FROM sysobjects where name like '" &
BaseTable & "'"

rstVerifyTable.Open


If rstVerifyTable.EOF = True Then

writePretty "<BR>Table Doesn't Exist :" & BASETABLE & ""

response.end

End If

'get all fields from base table

Dim rstAllFields

Set rstAllFields = Server.createobject("ADODB.Recordset")

rstAllFields.ActiveConnection = Session("cnn")

rstAllFields.Source = "select TOP 1 * FROM [" & BaseTable & "]"

rstAllFields.Open


If rstAllFields.EOF = True Then

writePretty "<BR>Base Table Doesn't Exist :" & BASETABLE & ""

response.end

End If

writePretty "<B>DAPID = " & DAPID & "</B>"

Call writeHtmlHead(DAPID)

Call writeTitle(DAPID, DAPTITLE)

Call writeDscHeader(DAPID)

Call writeConnectionString(DAPID, Application("cnnString"))

Call writeFieldSetHeader(DAPID)

Call writeFieldSets(DAPID, rstAllFields)

Call writeFieldSetFooter(DAPID)

Call writeGroupLevel(DAPID, BASETABLE)

Call writeDscFooter(DAPID)

Call WriteDapStyles(DAPID)

Call WriteDocProperties(DAPID)

Call WriteDapValidation(DAPID)

Call writeFormHeader(DAPID)

Call writeHeader(DAPID)

Call writeLabelHeader(DAPID)

Call writeLabels(DAPID)

Call writeLabelFooter(DAPID)

Call writeFieldHeader(DAPID)

Call writeFields(DAPID)

Call writeFieldFooter(DAPID)

Call writeNavigation(DAPID)

Call writeFormFooter(DAPID)

Call writeFooter(DAPID)

End Sub

'-----------------------------------------------------

Sub writeFormStart(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeFormStart-->" & CHR(13) & CHR(10)

Dim S_formName

Dim S_action


writePretty "<FORM NAME='form" & DAPID & "' method='POST'
action='pageD_1.asp?DAPID=" & DAPID & "' id='form" & DAPID & "'>"

End Sub

'-----------------------------------------------------

Sub writeFormEnd(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeFormEnd-->" & CHR(13) & CHR(10)

writePretty "</FORM>"

End Sub

'-----------------------------------------------------

Sub writeHtmlHead(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeHtmlHead-->" & CHR(13) & CHR(10)

writePretty "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>"

writePretty "<HTML xmlns='http://www.w3.org/TR/REC-html40' xmlns:eek: = "

writePretty "'urn:schemas-microsoft-com:eek:ffice:eek:ffice' xmlns:x = "

writePretty "'urn:schemas-microsoft-com:eek:ffice:excel' xmlns:a = "

writePretty "'urn:schemas-microsoft-com:eek:ffice:access' xmlns:dt = "

writePretty "'uuid:C2F41010-65B3-11d1-A29F-00AA00C14882'>"

'writePretty "<HEAD>"

End Sub

'-----------------------------------------------------

Sub writeTitle(DAPID, TITLE)

writePretty CHR(13) & CHR(10) & "<!-- writeTitle-->" & CHR(13) & CHR(10)

' writePretty "<TITLE>" & TITLE & "</TITLE>"

writePretty "<B>" & TITLE & "</B>"

End Sub

'-----------------------------------------------------

Sub writeDscHeader(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeHeader-->" & CHR(13) & CHR(10)

writePretty "<META content=Access.Application name=ProgId>"

writePretty "<META name=VBSForEventHandlers VALUE='TRUE'>"

writePretty "<META http-equiv=Content-Type content='text/html;
charset=windows-1252'>"

writePretty "<META content=10.00.2225 name=DesignerVersion>"

writePretty "<META content='HTML 4.0' name=vs_targetSchema>"

writePretty "<OBJECT id=MSODSC tabIndex=-1
classid=CLSID:0002E553-0000-0000-C000-000000000046>"

writePretty "<PARAM NAME='XMLData' VALUE=" & CHR(34)

writePretty "<xml xmlns:a='urn:schemas-microsoft-com:eek:ffice:access'>"

writePretty "<a:DataSourceControl>"

writePretty "<a:OWCVersion>10.0.0.2621</a:OWCVersion>"

End Sub

'-----------------------------------------------------

Sub writeConnectionString(DAPID, cnnString)

writePretty CHR(13) & CHR(10) & "<!-- writeConnectionString-->" & CHR(13) &
CHR(10)

writePretty "<a:ConnectionString>"

writePretty cnnString

writePretty "</a:ConnectionString>"

Exit Sub

writePretty "<a:ConnectionString>"

writePretty "Provider=SQLOLEDB.1;"

writePretty "Integrated Security=SSPI;"

writePretty "Persist Security Info=False;"

writePretty "Initial Catalog=VAPS_20050328;"

writePretty "Data Source=PDC;"

writePretty "Use Procedure for Prepare=1;"

writePretty "Auto Translate=True;"

writePretty "Packet Size=4096;"

writePretty "Workstation ID=SQL3;"

writePretty "Use Encryption for Data=False;"

writePretty "Tag with column collation when possible=False"

writePretty "</a:ConnectionString>"

End Sub

'-----------------------------------------------------

Sub writeFieldSetHeader(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeFieldSetHeader-->" & CHR(13) &
CHR(10)

writePretty "<a:MaxRecords>100000</a:MaxRecords>"

writePretty "<a:GridX>24</a:GridX>"

writePretty "<a:GridY>24</a:GridY>"

writePretty "<a:OfflineType>2</a:OfflineType>"

writePretty "<a:OfflinePublication></a:OfflinePublication>"

writePretty "<a:XMLLocation>0</a:XMLLocation>"

writePretty "<a:XMLDataTarget></a:XMLDataTarget>"

writePretty "<a:ConnectionFile></a:ConnectionFile>"

writePretty "<a:ElementExtension>"

writePretty "<a:ElementID>D_IONavLabel</a:ElementID>"

writePretty "<a:RecordsetLabel>D_IO |0 of |2;D_IO |0-|1 of
|2</a:RecordsetLabel>"

writePretty "</a:ElementExtension>"

End Sub

'-----------------------------------------------------

Sub writeFieldSets(DAPID, rstFields)

writePretty CHR(13) & CHR(10) & "<!-- writeFieldSets-->" & CHR(13) & CHR(10)

Dim i

Dim fldName

i = 0

For i = 0 to (rstFields.fields.count - 1)

fldName = rstFields.fields(i).name

If Len(fldName) = 0 Then writePretty "<BR>Zero-Length fldName detected: i =
" & i & "<BR>"

writePretty "<a:ElementExtension>"

writePretty "<a:ElementID>" & fldName & "</a:ElementID>"

writePretty "<a:ControlSource>" & fldName & "</a:ControlSource>"

writePretty "<a:ChildLabel>" & fldName & "_Label</a:ChildLabel>"

writePretty "</a:ElementExtension>"

Next

End Sub

'-----------------------------------------------------

Sub writeFieldSetFooter(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeFieldSetFooter-->" & CHR(13) &
CHR(10)

writePretty "<a:Datamodel a:version='0816'>"

End Sub

'-----------------------------------------------------

Sub writeDscFooter(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeFieldSetFooter-->" & CHR(13) &
CHR(10)

writePretty "<a:SchemaRowsource a:id='dbo.D_IO' a:type='dscTable'>"

writePretty "<a:SchemaField a:id='IoNumber' a:datatype='3' a:size='4'
a:iskey='1'/>"

writePretty "<a:SchemaField a:id='IoDescription' a:datatype='200'
a:size='255'/>"

writePretty "<a:SchemaField a:id='CAMPAIGN' a:datatype='200' a:size='20'/>"

writePretty "<a:SchemaField a:id='SUBCAMPAIGN' a:datatype='200'
a:size='20'/>"

writePretty "<a:SchemaField a:id='BUSINESSOWNER' a:datatype='200'
a:size='50'/>"

writePretty "<a:SchemaField a:id='LASTPARSEDATE' a:datatype='135'
a:size='8'/>"

writePretty "<a:SchemaField a:id='ISTMP' a:datatype='11' a:size='1'/>"

writePretty "<a:SchemaField a:id='PROFITCENTER' a:datatype='129'
a:size='6'/>"

writePretty "<a:SchemaField a:id='F_CHARGESCT' a:datatype='3' a:size='4'/>"

writePretty "<a:SchemaField a:id='DATEENTERED' a:datatype='135'
a:size='4'/>"

writePretty "<a:SchemaField a:id='ENTEREDBY' a:datatype='200' a:size='50'/>"

writePretty "<a:SchemaField a:id='F_OPENPOCT' a:datatype='3' a:size='4'/>"

writePretty "</a:SchemaRowsource>"

writePretty "<a:RecordsetDef a:id='D_IO' a:source='dbo.D_IO'>"

writePretty "<a:pageField a:id='IoNumber'/>"

writePretty "<a:pageField a:id='IoDescription'/>"

writePretty "<a:pageField a:id='CAMPAIGN'/>"

writePretty "<a:pageField a:id='SUBCAMPAIGN'/>"

writePretty "<a:pageField a:id='BUSINESSOWNER'/>"

writePretty "<a:pageField a:id='LASTPARSEDATE'/>"

writePretty "<a:pageField a:id='ISTMP'/>"

writePretty "<a:pageField a:id='PROFITCENTER'/>"

writePretty "<a:pageField a:id='F_CHARGESCT'/>"

writePretty "<a:pageField a:id='DATEENTERED'/>"

writePretty "<a:pageField a:id='ENTEREDBY'/>"

writePretty "<a:pageField a:id='F_OPENPOCT'/>"

writePretty "</a:RecordsetDef>"

writePretty "</a:Datamodel>"

writePretty "</a:DataSourceControl>"

writePretty "</xml>'></OBJECT>"

writePretty "<META content='MSHTML 6.00.2800.1476' name=GENERATOR>"









End Sub

'-----------------------------------------------------

Sub writeGroupLevel(DAPID, BASETABLE)

writePretty CHR(13) & CHR(10) & "<!-- writeGroupLevel-->" & CHR(13) &
CHR(10)

writePretty "<a:GroupLevel>"

writePretty "<a:RecordSource>" & BASETABLE & "</a:RecordSource>"

writePretty "<a:DefaultSort></a:DefaultSort>"

writePretty "<a:HeaderElementId>HeaderDIO</a:HeaderElementId>"

writePretty "<a:FooterElementId></a:FooterElementId>"

writePretty "<a:CaptionElementId>CaptionDIO</a:CaptionElementId>"

writePretty
"<a:RecordNavigationElementId>NavigationDIO</a:RecordNavigationElementId>"

writePretty "<a:DataPageSize>10</a:DataPageSize>"

writePretty "<a:GroupFilterControl></a:GroupFilterControl>"

writePretty "<a:AlternateRowColor>#E6E6E6</a:AlternateRowColor>"

writePretty "</a:GroupLevel>"

End Sub

'-----------------------------------------------------

Sub writeHeader(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeHeader-->" & CHR(13) & CHR(10)

writePretty ""


End Sub

'-----------------------------------------------------

Sub WriteDapStyles(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- WriteDapStyles-->" & CHR(13) & CHR(10)

Dim S_URL

S_URL = Server.MapPath("incStyles.inc")

WriteUrl(S_URL)



End Sub

'-----------------------------------------------------

Sub writeLabelHeader(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeLabelHeader-->" & CHR(13) &
CHR(10)

writePretty ""


End Sub

'-----------------------------------------------------

Sub writeLabels(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeLabels-->" & CHR(13) & CHR(10)

writePretty ""


End Sub

'-----------------------------------------------------

Sub writeLabelFooter(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeLabelFooter-->" & CHR(13) &
CHR(10)

writePretty ""


End Sub

'-----------------------------------------------------

Sub writeFieldHeader(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeFieldHeader-->" & CHR(13) &
CHR(10)

writePretty ""


End Sub

'-----------------------------------------------------

Sub writeFields(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeField-->" & CHR(13) & CHR(10)

writePretty ""


End Sub

'-----------------------------------------------------

Sub writeFieldFooter(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeFieldFooter-->" & CHR(13) &
CHR(10)

writePretty ""


End Sub

'-----------------------------------------------------

Sub WriteDocProperties(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeProperties-->" & CHR(13) &
CHR(10)

writePretty "<!--[if gte mso 9]>"

writePretty "<XML>"

writePretty "<o:DocumentProperties>"

writePretty "<o:Author>aaron kempf</o:Author>"

writePretty "<o:LastAuthor>aaron kempf</o:LastAuthor>"

writePretty "<o:Revision>1</o:Revision>"

writePretty "<o:TotalTime>0</o:TotalTime>"

writePretty "<o:Created>2005-03-13T22:56:15Z</o:Created>"

writePretty "<o:LastSaved>2005-03-13T22:56:57Z</o:LastSaved>"

writePretty "<o:Version>10.2625</o:Version>"

writePretty "</o:DocumentProperties>"

writePretty "<o:OfficeDocumentSettings>"

writePretty "<o:DownloadComponents/>"

writePretty "<o:LocationOfComponents Href='file:///\\'/>"

writePretty "</o:OfficeDocumentSettings>"

writePretty "</xml>"

writePretty "<![endif]->"

End Sub

'----------------------------------------------------

Sub WriteDapValidation(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- WriteDapValidation-->" & CHR(13) &
CHR(10)

Dim S_URL

S_URL = Server.MapPath("incDAP_validation.inc")

WriteUrl(S_URL)

End Sub

'----------------------------------------------------

Sub writeNavigation(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeNavigation-->" & CHR(13) &
CHR(10)

writePretty "<TBODY>"

writePretty "<TR>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavFirst id=D_IONavFirst tabIndex=1 height=20
src='owc://GIF/#11200' width=20></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavPrevious id=D_IONavPrevious tabIndex=2 height=20
src='owc://GIF/#11202' width=20></TD>"

writePretty "<TD style='VERTICAL-ALIGN: middle; WIDTH: 100%; TEXT-ALIGN:
center' noWrap><SPAN class=MsoNavRecordsetLabel id=D_IONavLabel
style='VISIBILITY: hidden' tabIndex=3>D_IO |0-|1 of |2</SPAN></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavNext id=D_IONavNext tabIndex=4 height=20 src='owc://GIF/#11204'
width=20></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavLast id=D_IONavLast tabIndex=5 height=20 src='owc://GIF/#11206'
width=20></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavAddNew id=D_IONavNew tabIndex=6 height=20 src='owc://GIF/#11208'
width=20></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavDelete id=D_IONavDelete tabIndex=7 height=20
src='owc://GIF/#11210' width=20></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavSave id=D_IONavSave tabIndex=8 height=20 src='owc://GIF/#11214'
width=20></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavUndo id=D_IONavUndo tabIndex=9 height=20 src='owc://GIF/#11212'
width=20></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavSortAsc id=D_IONavSortAscending tabIndex=10 height=20
src='owc://GIF/#11216' width=20></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavSortDesc id=D_IONavSortDescending tabIndex=11 height=20
src='owc://GIF/#11218' width=20></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavFilter id=D_IONavFilterBySelection tabIndex=12 height=20
src='owc://GIF/#11220' width=20></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavToggleFilter id=D_IONavFilterToggle tabIndex=13 height=20
src='owc://GIF/#11222' width=20></TD>"

writePretty "<TD class=MsoNavButton style='WIDTH: 20px; HEIGHT: 20px'><IMG
class=MsoNavHelp id=D_IONavHelp tabIndex=14 height=20 src='owc://GIF/#11224'
width=20></TD>"

writePretty "</TR></TBODY>"

End Sub

'----------------------------------------------------

Sub writeFormHeader(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeFormHeader-->" & CHR(13) &
CHR(10)

End Sub

'----------------------------------------------------

Sub writeFormFooter(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeFormFooter-->" & CHR(13) &
CHR(10)

End Sub

'----------------------------------------------------

Sub writeHeader(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeHeader-->" & CHR(13) & CHR(10)

End Sub

'----------------------------------------------------

Sub writeFooter(DAPID)

writePretty CHR(13) & CHR(10) & "<!-- writeFooter-->" & CHR(13) & CHR(10)

End Sub

'-----------------------------------------------------

Sub WritePretty(S_IN)

S_IN = replace(S_IN, "<", vbcrlf & "<")

response.write S_IN

End Sub

'-----------------------------------------------------

Sub WriteUrl(S_URL)

dim fso

dim text

dim readfile

dim contents

set fso = Server.CreateObject("Scripting.FileSystemObject")

set readfile = fso_OpenTextFile(S_URL, 1, false)

Response.Write readfile.ReadAll

readfile.close

Set fso = nothing

Set text = nothing

Set readfile = nothing

Set contents = nothing



End Sub

'-----------------------------------------------------

Sub WriteStandard0Filter(BO_Filter, CO_Filter, table)

'troubleshooting, printing HTML comment with all pertinent variables

response.write "<!-- " & vbcrlf

response.write "IsController = " & Session("IsController") & vbcrlf

response.write "IsBusinessOwner = " & Session("IsBusinessOwner") & vbcrlf

response.write "Filter1 = " & Session("Filter1") & vbcrlf

response.write "Filter2 = " & Session("Filter2") & vbcrlf

response.write "BO_Filter = " & BO_Filter & vbcrlf

response.write "CO_Filter = " & CO_Filter & vbcrlf

response.write "table " & table & vbcrlf

response.write " -->" & vbcrlf

Dim ServerFilter

Dim IsController

'handle when someone is a controller; but they dont have any ProfitCenters
assigned.

'this would only happen when someone is a controller but doesnt have any PC
assigned.

'this testCase is currently assigned to Brian and JohnR.

IsController = Session("IsController")

If CO_Filter = 1 AND Len(Trim(Session("Filter1"))) < 6 then

response.write "<!-- Filter1 less than 6 chars; pretending that we're not a
controller (for this procedure) -->" & vbcrlf

IsController = 0

End If

'we dont need to check if someone is a controller; since this should be
secure either way

'utilizing OnlyController for permissions

If CO_Filter = 1 then

ServerFilter = Session("Filter1")

If BO_Filter = 1 then

ServerFilter = ServerFilter & " OR " & Session("Filter2")

End If

Else

If BO_Filter = 1 then

ServerFilter = Session("Filter2")

End If

End If

If Len(trim(ServerFilter)) < 5 then ServerFilter = "1 = 0"

Response.write "<!--"

Response.write "<ServerFilter>" & vbcrlf

Response.write ServerFilter & vbcrlf

Response.write "</ServerFilter>" & vbcrlf

Response.write "-->"

response.write vbcrlf

Response.write "<SCRIPT language='vbscript'>" & vbcrlf

Response.write "Sub StandardOFilter()" & vbcrlf

Response.write " document.all(" & Chr(34) & "MSODSC" & Chr(34) &
").RecordsetDefs(" & Chr(34) & table & Chr(34) & ").ServerFilter = " &
Chr(34) & ServerFilter & Chr(34) & vbcrlf

Response.write "End Sub " & vbcrlf

Response.write "Sub Window_onLoad()" & vbcrlf

Response.write " StandardOFilter" & vbcrlf

Response.write "End Sub " & vbcrlf

Response.write "</SCRIPT>" & vbcrlf



End Sub

'-------------------------------------------------------

Sub Write0Filter(BO_Filter, CO_Filter, table)

'troubleshooting, printing HTML comment with all pertinent variables

response.write "<!-- " & vbcrlf

response.write "IsController = " & Session("IsController") & vbcrlf

response.write "IsBusinessOwner = " & Session("IsBusinessOwner") & vbcrlf

response.write "BO_Filter = " & BO_Filter & vbcrlf

response.write "CO_Filter = " & CO_Filter & vbcrlf

response.write "table " & table & vbcrlf

response.write " -->" & vbcrlf

Dim ServerFilter

If CO_Filter = 1 then

ServerFilter = "USERALIAS = '" & Session("pAlias") & "'"

If BO_Filter = 1 then

ServerFilter = ServerFilter & " OR USERALIAS = '" & Session("pAlias") & "'"

End If

Else

If BO_Filter = 1 then

ServerFilter = "USERALIAS = '" & Session("pAlias") & "'"

End If

End If

If Len(trim(ServerFilter)) < 5 then ServerFilter = "1 = 0"

Response.write "<!--"

Response.write "<ServerFilter>" & vbcrlf

Response.write ServerFilter & vbcrlf

Response.write "</ServerFilter>" & vbcrlf

Response.write "-->"

response.write vbcrlf

Response.write "<SCRIPT language='vbscript'>" & vbcrlf

Response.write "Sub StandardOFilter()" & vbcrlf

Response.write " document.all(" & Chr(34) & "MSODSC" & Chr(34) &
").RecordsetDefs(" & Chr(34) & table & Chr(34) & ").ServerFilter = " &
Chr(34) & ServerFilter & Chr(34) & vbcrlf

Response.write "End Sub " & vbcrlf

Response.write "Sub Window_onLoad()" & vbcrlf

Response.write " StandardOFilter" & vbcrlf

Response.write "End Sub " & vbcrlf

Response.write "</SCRIPT>" & vbcrlf



End Sub



%>
 
A

Aaron Kempf

this ended up being a much much greater solution.. basically I didn't write
the whole DAP from scratch..

I just made a DAP and then I made a WRAPPER in ASP that would do things like
filtering; etc

note the procedure
WriteStandardFilter




<!--#include file="borderTop.asp"-->
<!--#include file="borderNone.asp"-->
<!--#include file="incDap.inc"-->

<%
Call OnlyController
Call WriteDap(3)
Call WriteStandard0Filter(0, 1, "D_PROFITCENTER")
%>
<BR>If you do not have the ProfitCenters that you expect, please contact <a
href="mailto:[email protected]">XXXXX</a> and ask him to assign you as the
controller for that ProfitCenter

<!--#include file="borderRight.asp"-->
<!--#include file="borderBottom.asp"-->





Sub Write0Filter(BO_Filter, CO_Filter, table)
'troubleshooting, printing HTML comment with all pertinent variables
response.write "<!-- " & vbcrlf
response.write "IsController = " & Session("IsController") & vbcrlf
response.write "IsBusinessOwner = " & Session("IsBusinessOwner") & vbcrlf
response.write "BO_Filter = " & BO_Filter & vbcrlf
response.write "CO_Filter = " & CO_Filter & vbcrlf
response.write "table " & table & vbcrlf
response.write " -->" & vbcrlf

Dim ServerFilter

If CO_Filter = 1 then
ServerFilter = "USERALIAS = '" & Session("pAlias") & "'"
If BO_Filter = 1 then
ServerFilter = ServerFilter & " OR USERALIAS = '" & Session("pAlias") &
"'"
End If
Else
If BO_Filter = 1 then
ServerFilter = "USERALIAS = '" & Session("pAlias") & "'"
End If
End If

If Len(trim(ServerFilter)) < 5 then ServerFilter = "1 = 0"

Response.write "<!--"
Response.write "<ServerFilter>" & vbcrlf
Response.write ServerFilter & vbcrlf
Response.write "</ServerFilter>" & vbcrlf
Response.write "-->"
response.write vbcrlf

Response.write "<SCRIPT language='vbscript'>" & vbcrlf
Response.write "Sub StandardOFilter()" & vbcrlf
Response.write " document.all(" & Chr(34) & "MSODSC" & Chr(34) &
").RecordsetDefs(" & Chr(34) & table & Chr(34) & ").ServerFilter = " &
Chr(34) & ServerFilter & Chr(34) & vbcrlf
Response.write "End Sub " & vbcrlf
Response.write "Sub Window_onLoad()" & vbcrlf
Response.write " StandardOFilter" & vbcrlf
Response.write "End Sub " & vbcrlf
Response.write "</SCRIPT>" & vbcrlf


End Sub
 
D

David W. Fenton

Is there anything that I can do to run a macro from a DAP?

Not many people here use DAPs, because they never worked very well
except in the most limited circumstances. They are now being
deprecated by MS, but have not had any really serious development on
them since the original release in Access 2000.

I've never even tried them.

I just don't consider them an appropriate use of Access.

Of course, I also don't use macros, because I don't consider *those*
an appropriate use of Access!
 
L

Larry Linson

Drew said:
Is there a simple way to run a macro/query
from a Data Access Page. I am not
a programmer, so the simplest method
would be preferred.

What no one has bothered to tell you so far is that you don't use VBA with
DAPs, but either vbscript or javascript. You can use ADO (ActiveX Data
Objects) code with vbscript or javascript to handle data (the query
question) or you can perform various actions (as aaron said) with the
vbscript or javascript code itself. AFAIK, you can't use Access macros in
DAP.

Despite aaron's affection for them, the most accurate summation of DAPs in
this thread is the one by David Fenton. DAPs have, indeed, been deprecated
by Microsoft in Access 2007... you can run the ones you have, but you cannot
use Access 2007 to either create a new DAPs nor maintain old DAPs. If you
have DAPs and wish to maintain them, you'll need to keep your copy of Access
2000, 2002, or 2003 installed when/if you move to Access 2007.

It is a shame that aaron feels it's necessary to insult and try to harm
users of Microsoft software by posting incomplete, inaccurate, and
misleading information, just because he has "issues" with Microsoft over
their past relationship. And, it is a shame that his trolling in that manner
sometimes diverts knowledgeable responders from providing the detail that
you need in their answers.

Larry Linson
Microsoft Access MVP
 
A

Aaron Kempf

THEY NEVER WORKED WELL?

sorry, kid

they work _GREAT_

I'm just sorry that you're an Access _CRYBABY_ that doesnt know web
development
 
A

Aaron Kempf

DAPs _WORK_GREAT_

Microsoft promised us that we could take Access forms and reports and open
them with Visual Studio

I've seen this whole 'prototype _IS_ the application' in various places

and where is it.. IS IT HERE?

I'm tired of Microsoft failing to deliver


DAP is a great solution
The PivotList control of the Office Web Components family-- is more powerful
than any reporting tool ever used by any of the MDB dorks around here

I urge you to consider them for short-term projects

and don't under-estimate the amount of coding necessary


there isn't _ANYTHING_ELSE_IN_THE_WORLD_ that gives as pleasant of a
data-entry experience as DAP
 
A

Aaron Kempf

Jerry;

I don't believe you... sorry

_ANYONE_ that knew a real database wouldn't use MDB for anything

Your life would be SOOOO much easier with Access Data Projects and SQL
Server

and you wouldn't have to spend THREE TIMES AS MANY LICENSING FEES

what.. do you buy a new copy of TOAD every year?

MY IDE IS FREE KID, IT IS INCLUDED WITH OFFICE
 
A

Aaron Kempf

and with Oracle, no wonder you've got to make your users choose between
performance and functionality

I used to work for a small company with a half dozen oracle dorks

they -- collectively-- couldn't get 1/2 as much done on the database side as
I could
 
Top