Data Access Page combobox don't function

T

Tom

Ok, I have searched high and low for this and can't find the answer. Please
help.
I'm converting a form that contains a combobox to a Data Access Page. In the
Form the combobox contains a list of companies, when I select a company the
fields in the form is populated with info on that company. This function as
expected.

Converting the form to a DAP, the combobox still contain the list of
companies, although selecting the company nolonger populate the fields. The
rest of the DAP works.

I read through using MS Access 2002 and found that converting Forms to DAP,
the buttons and combobox will nolonger function because you need some
VBScript. or JavaScript.

Can anyone help me with this, I need some sample code to get the List Box on
the DAP to populate the rest of the form when a company in the List Box is
selected.

Thanks.
 
J

Joe Fallon

I have not looked at DAPs for a long time.
But here is osme old code from the one I built many years ago.
Hopefully it can sprak some ideas for you.

Create a Stored Procedure that accepts a search term:

CREATE Procedure dbo.uspName @searchtext VARCHAR(2000)
AS
SELECT ID, Field1, Field2, Field3
FROM MyTable
WHERE Field1 Like '%' + @searchtext + '%'
OR Field2 Like '%' + @searchtext + '%'
OR Field3 Like '%' + @searchtext + '%'

--the contains clause below is used for Full Text Search. Replace where
clause if FTS is enabled.
--WHERE CONTAINS(*,@searchtext)
ORDER BY ID
RETURN
GO

'Create a textbox to enter the search term and a button named btnSearch to
call this code:

<SCRIPT language=vbscript event=onclick for=btnSearch>
If txtSearch.value <> "" Then
FindText()
Else
MsgBox("Please enter a search string.")
End If
</SCRIPT>

<SCRIPT language=vbscript>
Sub FindText()
Dim rst
adUseServer=2
adOpenStatic=3
adLockOptimistic=3

Set rst = CreateObject("ADODB.Recordset")

rst.CursorLocation = adUseServer
'call a stored procedure that takes a parameter
rst.Source = "uspName '" & txtSearch.value & "'"
rst.ActiveConnection =
MSODSC.DataPages.Item(0).Recordset.ActiveConnection
rst.CursorType = adOpenStatic
rst.LockType = adLockOptimistic
rst.Properties("Unique Table").Value ="MyTable"
rst.Open

'I have a few cbos that filter the original recordset. I want the
existing filter to apply to the search
'results above. If you are just searching the entire table, then you can
omit this.
Dim strWhere
If cboID.value <> "" Then
strWhere = strWhere & "ID=" & cboID.value & " AND "
End If
If cbo2.value <> "" Then
strWhere = strWhere & "Field2ID=" & cbo2.value & " AND "
End If
If cbo3.value <> "" Then
strWhere = strWhere & "Field3ID=" & cbo3.value & " AND "
End If
If cbo4.value <> "" Then
strWhere = strWhere & "Field4ID=" & cbo4.value & " AND "
End If

If strWhere = "" Then
rst.Filter = ""
Else
strWhere = Left(strWhere, Len(strWhere) - 5)
rst.Filter = strWhere
End If

'swap out the original bound data with the search results
MSODSC.SetRootRecordset "MyTable", rst

End Sub
</SCRIPT>

'Create a Reset button to re-load the original page. (Simplest method for
starting over).
<SCRIPT language=vbscript event=onclick for=btnReset>
're-load the page.
window.navigate("MyDAP.htm")
</SCRIPT>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top