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

Need help translating SQL code in Access VB code

Status
Not open for further replies.

nalbiso

Programmer
Aug 31, 2000
71
US
I am relatively new to VB programming, please help.

This is probably really long and redundant code but I am trying to create a sqlstr that prompts a user for a parameter in Access 97 using VB. The SQL view in an Access query looks like this:

SELECT dbo_jobint.First_Name, dbo_jobint.Last_Name, dbo_jobint.Address, dbo_jobint.City, dbo_jobint.State, dbo_jobint.Zip_Code, dbo_jobint.Title_of_Position, dbo_jobint.Job_Code, dbo_jobint.Available_to_Substitute, dbo_jobint.Email_Address INTO [Mail Job Interest]
FROM dbo_jobint
WHERE (((dbo_jobint.Job_Code)=[Enter the Job Code of the Position:]) AND ((dbo_jobint.Preferred_Method_of_Contact)="All Contact Methods" Or (dbo_jobint.Preferred_Method_of_Contact)="Email") AND ((dbo_jobint.[Contacted By])="Not Contacted Yet") AND ((dbo_jobint.[Date Contacted])="Not Contacted"));

How do I create this in a VB code?

I may be asking this question wrong so please bare with me.

Thanks [sig][/sig]
 
Hi,

function fct()
dim sqlstr as string
dim db as database
dim qrdf as querydef
set db=currentdb()
sqlstr="SELECT dbo_jobint.First_Name, dbo_jobint.Last_Name,
dbo_jobint.Address, dbo_jobint.City, dbo_jobint.State, dbo_jobint.Zip_Code, dbo_jobint.Title_of_Position, dbo_jobint.Job_Code, dbo_jobint.Available_to_Substitute, dbo_jobint.Email_Address INTO [Mail Job Interest]
FROM dbo_jobint
WHERE (((dbo_jobint.Job_Code)=[Enter the Job Code of the Position:]) AND ((dbo_jobint.Preferred_Method_of_Contact)='All Contact Methods' Or (dbo_jobint.Preferred_Method_of_Contact)='Email') AND ((dbo_jobint.[Contacted By])='Not Contacted Yet') AND ((dbo_jobint.[Date Contacted])='Not Contacted'));"
set qrdf=db.createquerydef("anything",sqlstr)

Ist what you want?
Bye


[sig][/sig]
 
I ended up figuring it out.

Thanks! [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top