Connecting Tech Pros Worldwide Help | Site Map

copy multiple fields from one table to another

news.hp.com
Guest
 
Posts: n/a
#1: Nov 12 '05
I have situation where I need to copy multiple records (only certain fields)
from a Rules table to an Events table based on a selection identified in a
combo box. When the selection is made in a parent table, multiple records
in a child table are affected. However, I'm a bit weak on programming
experience. INSERT INTO is not suitable. Any ideas?

When the combo box update property is triggered, the code needs to
accomplish:

IF rules don't exist in Events table, then copy from Rules table
FOR each row needed
create row in Events table for each qualified record in Rules table
copy fields from Rules table to Events table (thinking of using an
append query here)
End For
ELSEIF rules are present in Events table, then update records in Events
table from records in Rules table
FOR each row
update fields from Rules table to Events table (thinking of using an
update query here)
end if

Thanks,
Grant


Pieter Linden
Guest
 
Posts: n/a
#2: Nov 12 '05

re: copy multiple fields from one table to another


"news.hp.com" <grant.ritz@hp.com> wrote in message news:<3fa68ad7$1@usenet01.boi.hp.com>...[color=blue]
> I have situation where I need to copy multiple records (only certain fields)
> from a Rules table to an Events table based on a selection identified in a
> combo box. When the selection is made in a parent table, multiple records
> in a child table are affected. However, I'm a bit weak on programming
> experience. INSERT INTO is not suitable. Any ideas?
>
> When the combo box update property is triggered, the code needs to
> accomplish:
>
> IF rules don't exist in Events table, then copy from Rules table
> FOR each row needed
> create row in Events table for each qualified record in Rules table
> copy fields from Rules table to Events table (thinking of using an
> append query here)
> End For
> ELSEIF rules are present in Events table, then update records in Events
> table from records in Rules table
> FOR each row
> update fields from Rules table to Events table (thinking of using an
> update query here)
> end if
>
> Thanks,
> Grant[/color]


If RulesExist=False '<--- you could use an outer join to determine this....
docmd.openQuery "qappAddRules" 'WHERE Rightside table. PK = Null
Else
Docmd.OpenQuery "qupdUpdateRules" 'Where RightsideTable.PK NOT NULL
End If


--Okay, now in something like semi-useful code...
DoCmd.SetWarnings False 'Only _AFTER_ the queries work manually...
DoCmd.OpenQuery "qupdRules"
DoCmd.OpenQuery "qappRules"
DoCmd.SetWarnings True

On Error
Msgbox Err.ErrNo & Err.Description
Err.Clear
Grant Ritz
Guest
 
Posts: n/a
#3: Nov 12 '05

re: copy multiple fields from one table to another


OK. You've given me some ideas to munch on...
Thanks, Grant

"Pieter Linden" <pietlinden@hotmail.com> wrote in message
news:bf31e41b.0311031543.1dcf728@posting.google.co m...[color=blue]
> "news.hp.com" <grant.ritz@hp.com> wrote in message[/color]
news:<3fa68ad7$1@usenet01.boi.hp.com>...[color=blue][color=green]
> > I have situation where I need to copy multiple records (only certain[/color][/color]
fields)[color=blue][color=green]
> > from a Rules table to an Events table based on a selection identified in[/color][/color]
a[color=blue][color=green]
> > combo box. When the selection is made in a parent table, multiple[/color][/color]
records[color=blue][color=green]
> > in a child table are affected. However, I'm a bit weak on programming
> > experience. INSERT INTO is not suitable. Any ideas?
> >
> > When the combo box update property is triggered, the code needs to
> > accomplish:
> >
> > IF rules don't exist in Events table, then copy from Rules table
> > FOR each row needed
> > create row in Events table for each qualified record in Rules[/color][/color]
table[color=blue][color=green]
> > copy fields from Rules table to Events table (thinking of using[/color][/color]
an[color=blue][color=green]
> > append query here)
> > End For
> > ELSEIF rules are present in Events table, then update records in Events
> > table from records in Rules table
> > FOR each row
> > update fields from Rules table to Events table (thinking of[/color][/color]
using an[color=blue][color=green]
> > update query here)
> > end if
> >
> > Thanks,
> > Grant[/color]
>
>
> If RulesExist=False '<--- you could use an outer join to determine[/color]
this....[color=blue]
> docmd.openQuery "qappAddRules" 'WHERE Rightside table. PK = Null
> Else
> Docmd.OpenQuery "qupdUpdateRules" 'Where RightsideTable.PK NOT NULL
> End If
>
>
> --Okay, now in something like semi-useful code...
> DoCmd.SetWarnings False 'Only _AFTER_ the queries work manually...
> DoCmd.OpenQuery "qupdRules"
> DoCmd.OpenQuery "qappRules"
> DoCmd.SetWarnings True
>
> On Error
> Msgbox Err.ErrNo & Err.Description
> Err.Clear[/color]


Closed Thread