Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search recordset

Status
Not open for further replies.

pazgb

Programmer
Jun 9, 2003
60
US
I need to have a module search through a table of each field on each record and get the field names if value is -1(which is checked) and return the field name(s)

im having trouble opening the recordset and searching

this is what i have so far


Public Function GetExceptions()


Set db = CurrentDb
Set rs = db.OpenRecordset("tblRTisPrintExcept", dbOpenTable)

rs.MoveFirst

Do Until rs.EOF
If rs.Fields(0).Value = [Forms]![frm_ReportsRetailDaily].lblDate.Caption Then
If rs.Fields(2).Value = -1 Then
exception = rs.Fields(2).Value
MsgBox rs.Fields(2).Value
GetExceptions = rs.Fields(2).Value
End If
End If
rs.MoveNext
Loop


rs.Close
db.Close


End Function



for some reason it doesnt seem like it is doing anything when the function is called, is there something wrong when im trying to return the variable

so i need this function to be executed in a report control and run multiple times.



 
I do not think you need the dbOpentable

Set rs = db.OpenRecordset("tblRTisPrintExcept", dbOpenTable)

Instead try
Set rs = db.OpenRecordset("tblRTisPrintExcept")

Try changing this to a text box instead of a label
[Forms]![frm_ReportsRetailDaily].lblDate.Caption Then
(Just a long shot)

also my be try
Public Function GetExceptions() as string
or
Public Function GetExceptions() as long
or what ever it is


I'm just guessing b/c you did not state the type of error.
What type of error are you getting?
 
Thank you for your help, i changed the label to a textbox and added public GetExceptions() as string to return the value!

Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top