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

For...Next parameter query.

Status
Not open for further replies.

Bambini

Technical User
Jan 22, 2001
2
IT
Is it possible, in an append query, to repete and increment a parameter in a for next loop and run the query whithout be asked by a prompt message to insert the new parameter value?
 
Yes it is:
'the code on a module
Dim xxx As Integer
Function getint() As Integer
getint = xxx
End Function

Function inserting()

xxx = 0
DoCmd.SetWarnings 0
DoCmd.OpenQuery ("query7")
xxx = 1
DoCmd.OpenQuery ("query7")
DoCmd.OpenQuery ("query7")
DoCmd.OpenQuery ("query7")
DoCmd.SetWarnings 1
End Function
'below the code of query7
INSERT INTO table2 ( x )
VALUES (getint());

table2 has two columns id-autonumber and x integer John Fill
1c.bmp


ivfmd@mail.md
 
Well,

John fill appears to be headed down the right path. Somewhere in all of the stufffffff, there needs to actually be a loop, and the "PARAMETER" is rather vague (the function GetInt). The declaration for xxx MUST be in the declaration section of a General module and it would be helpful to note this explicitly in the post (after all, Bambini would not be asking this if they were experts?).

In a more FORMAL appliction, I suspect that the use of an actual PARAMETER is necessary, to have the query select some data from a seperate recordset. this may also be accomplished in the loop, as long as the parameter value may be assigned on the basis of the loop index, but would require the query be defined and instantiated as a querydef.


MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top