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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter a Record to Print a DataReport

Status
Not open for further replies.

Quique79

Programmer
Dec 18, 2001
15
MX
Hi!!

I want to print a DataReport (Invoice), I have a form, where I'll select Invoice No. to print it.

My question goes to what can I do to take this text contained in Text1.txt to use it to filter a SQL query???

Please Help me!!!!

Any tip or hint will be helpful

Quique79
 
Private Sub FillRpt()
Set RptCustomers.DataSource = adoPrimaryRS
End Sub


Private Sub CmdPrint_Click()
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program.mdb;Jet OLEDB:Database Password=1"
Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "select [ID],[First Name],[Last Name] from Customers where ID like" & "'" & "'" & Text1.text & "'" , db, adOpenStatic, adLockOptimistic
FillRpt
RptCustomers.Show

End Sub


This may be a little sloppy but I just finished it myself.
Chop it apart at your will..
Hope it helps a little. Help with SQL is hard to find, I am learning also....
 
Hey Fastway!!

Thanks for your tip, but I can't do it, something is wrong...

In Access 2000 I used to write something like that in a Query Criteria Field [Field]=[Forms]![FormName]![FieldName] to filter, but SQL I don't know how...

Please help me!!!!

Quique79
 
adoPrimaryRS.Open "select [ID],[First Name],[Last Name] from Customers where ID like" & "'" & "'" & Text1.text & "'" , db, adOpenStatic, adLockOptimistic

[ID is a field] [Customers is the form]
Now we have data like Id, Firstname, Lastname, Address, Phone Number and so on are the Fields. This data is in the database table Customers. So we are selecting only Data from the Id, First name, and Last name Fields from Customers Table. This limits our output to only the selected fields. Ok now we need something to search from, so we Query from Customers Table using only the Field [ID] and the Data looks like your Text1.text.

The stuff like , db, adOpenStatic, adLockOptimistic are specific to how you are opening your database.

I hope you can understand this. I haven't done much SQL before and I am sorry If I didn't answer you very well. I had to learn SQL myself.
 
fastaway:

Thanks, I did understood... and it worked.. thanks!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top