How can I get the value of the listdisplayfield on a DAP

G

ghostmachine

Hello everyone,

I seem to be losing my mind. I have a data access page that has a list box
on it. The list box has two columns attached to it. They are companyname and
password.
Password is the listdisplayfield and companyname is the listboundfield. When
the user selects the company name from an above field the listbox moves to
the correct password in the listbox. I then need to take that password that
is being displayed and compare it to the value they entered. HOW CAN I GET
THE LISTDISPLAYFIELDS VALUE. Please help

Thank you in advance for your time and assistance
 
S

sparker

ghost,
is there any reason you can not call a function to retrieve the value for you?
So your statement would look something like:

If UserValue = GetCompanyPasswordValue(Me.ListBox.Value) Then
Call This
Else
Call That
End If

Public Function GetCompanyPasswordValue(pstrCompanyValue) As String

Dim daoDbs as DAO.Database
Dim daoRec as DAO.Recordset
Dim strSql as String

Set daoDbs = CodeDB

strSql = _
"Select MyTable.Password From MyTable " & _
"Where MyTable.Company = '" & pstrCompanyValue & "';"

Set daoRec = daoDbs.OpenRecordset(strSql)

If Not (daoRec.BOF and daoRec.EOF) Then
GetCompanyPasswordValue = daoRec("Password ").value
Else
GetCompanyPasswordValue = "Unknown"
End IF

strSql = ""
daoRec.Close
daoDbs.Close

End Function

If you need more help let me know. Take Care & God Bless ~ SPARKER ~
 
G

ghostmachine

Hello Sparker:

Thanks for the advice but it seems the code is for forms. I am working with
Data Access Pages. Also If I where to use a function I would be using Java so
that I can be OS independant. Any other suggestions?

Thank you in advance
 

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