On 2002-10-23 01:06, michan31 wrote:
I'm getting it little by litte, but I still have questions.
1. Can you tell me the meaning of the following code?
LASW10
The below code is effectively creating the SQL code that you would use to run your Query in Access. It's SQL code - and thus reads:
SELECT NOMINAL, YYMM, AMOUNT FROM FORECAST WHERE ID = IDNUM
IDNUM is simply a variable. So say IDNUM was the ID number that you put in cell A1 on sheet A1 in Excel...
At the top of your Macro (under the Sub MACRO_NAME()
You would specify what IDNUM is - e.g
IDNUM = Sheets("sheet1").range("a1")
So as far as Excel is concerned, whenever you quote IDNUM it will refer to Sheet1 A1
The rest of the code is simply setting up the qry (defining it) - don't worry about it too much - the main thing is to get the SQL right - so NOMINAL, YYMM, AMOUNT & ID are all columns in table FORECAST - and IDNUM will be specified in Sheet1 RangeA1 in Excel and will be one of the ID references in FORECAST table in Access - Column ID.
END MESSAGE
Set qry = dbs.CreateQueryDef(A, "SELECT NOMINAL, YYMM, AMOUNT FROM FORECAST WHERE ID = " & IDNUM & "")
2. Do I put the following code in the same place as others?
IDNUM = sheets("sheet1").range("a1")
Thanks.
I really appreciate you helping me.