ListBox not loading properly on form open

G

Guest

I use a private function to load some initial data onto a form with a list
box control. The listbox control should be filtered based on two unbound
controls: tAgent and tCode - these controls are loaded with data from the
private function.

The problem is that the listbox appears blank until the form is refreshed
(by an OnClick event in another list box). I'd like it to refresh
automatically, but putting the Refresh in the OnLoad event for the form
doesn't work.

here's the code I'm using to filter the listbox:

Public Function parseHP(sScreen As String)

Dim sPolicyNum As String
Dim sName As String
Dim sCode As String
Dim sState As String
Dim regX As New RegExp
Dim cMatches As MatchCollection
Dim oMatch As Match

sState = Trim(Mid(sScreen, InStr(sScreen, "ST-DIV") + 7, 2))

sName = Trim(Mid(sScreen, InStr(sScreen, "ST-DIV") + 52, 18))

regX.Pattern = "AGT-AFO\s(\d{4}|\w{4})"
Set cMatches = regX.Execute(sScreen)
Set oMatch = cMatches(0)
sCode = oMatch.SubMatches(0)

regX.Pattern = "INFO\sFOR\s(\d{3}\s\d{4}|\w{3}\s\d{4})"
Set cMatches = regX.Execute(sScreen)
Set oMatch = cMatches(0)
sPolicyNum = oMatch.SubMatches(0)

loadForm sPolicyNum, sName, sCode, sState

End Function

Public Function loadForm(sPolicyNum As String, sName As String, sCode As
String, sState As String)

With Forms!DataEntry
!Policy = sPolicyNum
!Name = sName
!tCode = sCode
!tState = sState
End With

End Function


Any suggestions?

Thanks!!!
SELECT tblPeople.PeopleID, tblPeople.LName, tblPeople.FName,
tblPeople.ReportsTo
FROM tblPeople
WHERE (((tblPeople.Code)=[tCode]) AND ((tblPeople.State)=[tState]))
GROUP BY tblPeople.PeopleID, tblPeople.LName, tblPeople.FName,
tblPeople.ReportsTo;


And here's the code I'm using to load the form:
 
G

Guest

At the end of the code where you update the list box use:

Me.YourListboxName.Requery

--


Bob Larson
HTH
:)
____________________________________
Access 2000, 2003, 2007, SQL Server 2000, Crystal Reports 10/XI, VB6
WinXP, and Vista
 

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