PDA

View Full Version : QueryDef Help



pundabuyer
11-23-2008, 06:00 AM
Private Sub Command0_Click()

Dim Db As Database
Dim Qd As QueryDef
Set Db = CurrentDb
Set Qd = Db.CreateQueryDef("Q1", "PARAMETERS EnterCriteria String;INSERT INTO tbl_Append ( CustomerID, CompanyName, ContactName, ContactTitle, Address, City, Region, PostalCode, Country, Phone, Fax ) SELECT Customers.CustomerID, Customers.CompanyName, Customers.ContactName, Customers.ContactTitle, Customers.Address, Customers.City, Customers.Region, Customers.PostalCode, Customers.Country, Customers.Phone, Customers.Fax FROM Customers WHERE (((Customers.CustomerID)=EnterCriteria));")

Qd!EnterCriteria = InputBox("Enter Name ID")

Qd.Close

End Sub

Norie
11-23-2008, 10:05 AM
Do you have a question/problem?:eek:

pundabuyer
11-23-2008, 03:27 PM
Hi there,

no specific problem as such i just dont know how to do what i described above...?

Norie
11-23-2008, 04:11 PM
Sorry, but I don't see any description of what you want to do.:eek:

pundabuyer
11-23-2008, 04:58 PM
I basically just want to be able to use querydefs in vba.

how would i use one to append all fields from tbl_customers to tbl_appended by using a criteria on CustomerID as a parameter?

If you look at top ive had a bash but i think its totally wrong, Its not a specific problem i would just like to know how to use them and what the difference is between:

querydefs()
and
createquerydef()

and what they actually do!!

CreganTur
11-24-2008, 06:38 AM
Look at my reply here: http://www.vbaexpress.com/forum/showthread.php?t=23750

Don't post multiple threads for the same question, give us a little time to get back to you with an answer ;)