like a macro

G

Guest

On Mainform for table1 (autorec=id) is a command button which opens and
displays a subform for table2 as a datasheet view (its id is long integer
duplicates allowed)
Me!subform.visible = true

I usually add and populate six records 6 records, the second field is named
TYPE
and I always have
record1 type A
record2 type B
record3 type C
:
record6 type F

so the parent child relationshipp is Mainform has ID =201 and it has 6
children in table2 all six with id = 201

Is there a way to do this:

Click commandbutton:
Me!subform.visible = true

Dim I
REM sort of like a loop For I = 1 to 6
CurrentDb.execute "Create a new record and then UPdate table2 SET fieldtype
= A
CurrentDb.execute "Create a new record and then UPdate table2 SET fieldtype
= B
:
:
CurrentDb.execute "Create a new record and then UPdate table2 SET fieldtype
= F



?
 
S

Stefan Hoffmann

hi Mark,

mark said:
Dim I
REM sort of like a loop For I = 1 to 6
CurrentDb.execute "Create a new record and then UPdate table2 SET fieldtype
= A
CurrentDb.Execute "INSERT INTO Table2 (ParentID, FieldType) " & _
"VALUES (" & ParentID & ", '" & Chr(64 + i)& "')"

mfG
--> stefan <--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top