Connecting Tech Pros Worldwide Help | Site Map

copy multiple fields from one table to another

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 03:02 PM
news.hp.com
Guest
 
Posts: n/a
Default copy multiple fields from one table to another

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



  #2  
Old November 12th, 2005, 03:03 PM
Pieter Linden
Guest
 
Posts: n/a
Default 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
  #3  
Old November 12th, 2005, 03:05 PM
Grant Ritz
Guest
 
Posts: n/a
Default 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]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.