Append query for temp table (1 Viewer)

pattie0928

New member
Local time
Today, 15:26
Joined
Dec 14, 2012
Messages
2
Hello,

I am trying to create a table from a form. The form has several fields but I need to take the value from 4 separate combo boxes ([cr] +[br] +[tr] and add them, then add the value from one more combo box [inc] to be my beginning value in a table.

I then need to add the last value [inc] to the total and that become the next line in the table. I would the like to add this value [inc] an infinite number of times until it reaches a max number.

The scenario would be something like this
cr=3 br=2 tr=3 inc=1.5

So the first total would be 9.5. Then every row after that would be plus 1.5
11
12.5
14
15.5
17
and so on.

This would be a temp table that I would run a query on to let an operator know lengths they can choose from in a combo box.

I don't know if this is even possible. Any ideas?

Thanks so much :)
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:26
Joined
Feb 19, 2013
Messages
16,663
Anything is possible. the code you would need would be something like

Code:
insertvalue=9.5
inc=1.5
while insertvalue<maxvalue
    currentdb.execute "INSERT INTO tmpTable (inc) VALUES(" & insertvalue & ")"
    insertvalue=insertvalue+inc
wend
This presumes the temp table already exists, if it doesn't then the code would be something like

Code:
insertvalue=9.5
inc=1.5
currentdb.execute "SELECT " & insertvalue & " AS Inc INTO tmpTable"
insertvalue=insertvalue+inc
while insertvalue<maxvalue
    currentdb.execute "INSERT INTO tmpTable (inc) VALUES(" & insertvalue & ")"
    insertvalue=insertvalue+inc
wend
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 06:26
Joined
Jan 20, 2009
Messages
12,856
Avoid the temp table and its associated problems. The job would be far better handled with a fabricated ADO recordset.

The loop would be similar to that supplied by CJ but adding the records to the fabricated recordset instead of the table.

At the end the combo's recordset property is set to the fabricated recordset.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:26
Joined
Feb 19, 2013
Messages
16,663
missed the bit about the combo box - in which case, you don't need the fabricated ADO recordset either - set the combobox rowsourcetype to valuelist and then use the following code

Code:
insertvalue=9.5
inc=1.5
myCombobox.rowsource=""
while insertvalue<maxvalue
    myCombobox.rowsource=myCombobox.rowsource & insertvalue &";"
    Insertvalue=insertvalue+inc
wend
 

Users who are viewing this thread

Top Bottom