Hi everyone. I'm not a programmer by career, so I may be unfamiliar with some terms. I have done VBA programming in Excel but now I want to foray into the Access database in my work. Gotta admit it has been harder than I thought. The mix of the DAO, ADO and DoCmd libraries have been giving me some trouble.
Anyway, right now I want to execute within a form an Access table creation action query with one entry parameter (let's call it GetWorkload from now on). I made it with the usual querybuilder view. To ilustrate my problem (although these you probably know well), I have tried the following:
- Creating an ADO recordset referencing the GetWorkLoad query. Problem: adcmdTable option will simply put SELECT * FROM... and will turn it into a selection query.
- Try to get the GetWorkLoad string with the .SQL property from QueryDef. Problem: for some odd reason Access doesn't get the CREATE TABLE part of the query creation table and only starts from the SELECT part. Which property or method can return that part? I cannot see it even in the SQL view.
- Using the DoCmd.OpenQuery method. Problem: the parameter value part from the QueryDef.Parameters collection is read only (why?), so I can't set the parameter using code.
A former employee bypassed this issue by referencing the field to the value of a hidden textbox in the form. I find this solution rather unelegant since it ties the query to the form and denies me from using it anywhere else. Of course, I can put all the CREATE TABLE SQL part right into the code, but then I alredy envision wasting HOURS debugging SQL sentences on the VBA editor, checking all the parenthesis, the multiple JOINs, etc.
I feel there has to be a way to switch off those user friendly barriers and display the DDL sentences used on the Access queries, or a way to work directly with the Access queries instead of recordsets that merely reference them.
Any help is appreciated.