PC Review


Reply
Thread Tools Rate Thread

UPDATE TABLE FROM UNBOUND QUERY

 
 
redthunder21 via AccessMonster.com
Guest
Posts: n/a
 
      17th Mar 2006
I have an Unbound Form that uses a query to gather certain data. Once this
data is int he query, I need to update another table. I want to update the 3
fields in the table - Moved = Yes, DateMoved = Today and TimeMoved = Now. I
am new to access and am struggling with the correct way to accomplish this.

My query is TestQuery and the ID's are the same in the query and the table
that I want to update. I can get the every record of the table field Moved
to change to yes, but I only want the RecordIDs from the query to be updated
in the table.

This is the code I have which updates the entire Moved field in the table:
DoCmd.RunSQL "UPDATE ScrapDataBuild SET scrapdatabuild.MOVED = " &
strCategory & ""

Can anyone help me with the code to select the matching ID's to update the
table? I am using Access2003 and I have tried numerous time to use the where
clause with no luck.

Thanks,
Dawn

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...dules/200603/1
 
Reply With Quote
 
 
 
 
strive4peace
Guest
Posts: n/a
 
      19th Mar 2006
Hi Dawn,

Rather than trying to construct the SQL, use the Design view
of the query

1. AddTables --> TestQuery, Tablename
(from the menu --> Query, Show Table)

2. link the query to the table on the ID field -->
click on the ID field of the table and DRAG to the ID field
of the query and then let go of the mouse

3. change the query to an UPDATE query
(from the menu --> Query, Update)

4. put the fields on the grid to update

drag the field from Tablename to the grid and fill in the
UpDateTo cell..

field -->Moved
tablename --> Tablename
UpdateTo --> Yes

field -->DateMoved
tablename --> Tablename
UpdateTo --> TestQuery.DateMoved

field -->TimeMoved
tablename --> Tablename
UpdateTo --> TestQuery.TimeMoved

then, Run!

alternately, you could store DateTimeMoved (since Date and
Time can be stored together) and update that to Now()

It seems that this is not the best logic to accomplish this
task... what is the criteria for TestQuery? Are you using a
temporary table?

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com


redthunder21 via AccessMonster.com wrote:
> I have an Unbound Form that uses a query to gather certain data. Once this
> data is int he query, I need to update another table. I want to update the 3
> fields in the table - Moved = Yes, DateMoved = Today and TimeMoved = Now. I
> am new to access and am struggling with the correct way to accomplish this.
>
> My query is TestQuery and the ID's are the same in the query and the table
> that I want to update. I can get the every record of the table field Moved
> to change to yes, but I only want the RecordIDs from the query to be updated
> in the table.
>
> This is the code I have which updates the entire Moved field in the table:
> DoCmd.RunSQL "UPDATE ScrapDataBuild SET scrapdatabuild.MOVED = " &
> strCategory & ""
>
> Can anyone help me with the code to select the matching ID's to update the
> table? I am using Access2003 and I have tried numerous time to use the where
> clause with no luck.
>
> Thanks,
> Dawn
>

 
Reply With Quote
 
redthunder21 via AccessMonster.com
Guest
Posts: n/a
 
      21st Mar 2006
Crystal,

I tried your suggestions, but they didn't work. The table that I need to
update is a table that Production Scans the bad inventory into and
categorizes it. On my unbound form, I am asking the following:

Category
Damage Type
Beginning Date
Ending Date
I also have a preview button and a print button on the form.

This buttons run the TestQuery and I can see the results. Based on the
results of the query, I want to update the main data tale with Moved = Yes,
DateMoved = Now and Time Moved = Now.

Is this unbound form really creating a temporary table? I have never used
temporary tables.

Thanks,
Dawn

strive4peace wrote:
>Hi Dawn,
>
>Rather than trying to construct the SQL, use the Design view
>of the query
>
>1. AddTables --> TestQuery, Tablename
>(from the menu --> Query, Show Table)
>
>2. link the query to the table on the ID field -->
>click on the ID field of the table and DRAG to the ID field
>of the query and then let go of the mouse
>
>3. change the query to an UPDATE query
>(from the menu --> Query, Update)
>
>4. put the fields on the grid to update
>
>drag the field from Tablename to the grid and fill in the
>UpDateTo cell..
>
>field -->Moved
>tablename --> Tablename
>UpdateTo --> Yes
>
>field -->DateMoved
>tablename --> Tablename
>UpdateTo --> TestQuery.DateMoved
>
>field -->TimeMoved
>tablename --> Tablename
>UpdateTo --> TestQuery.TimeMoved
>
>then, Run!
>
>alternately, you could store DateTimeMoved (since Date and
>Time can be stored together) and update that to Now()
>
>It seems that this is not the best logic to accomplish this
>task... what is the criteria for TestQuery? Are you using a
>temporary table?
>
>Have an awesome day
>
>Warm Regards,
>Crystal
>
>MVP Microsoft Access
>
>remote programming and training
>strive4peace2006 at yahoo.com
>
>> I have an Unbound Form that uses a query to gather certain data. Once this
>> data is int he query, I need to update another table. I want to update the 3

>[quoted text clipped - 16 lines]
>> Thanks,
>> Dawn


--
Message posted via http://www.accessmonster.com
 
Reply With Quote
 
strive4peace
Guest
Posts: n/a
 
      22nd Mar 2006
Hi Dawn,

perhaps I am missing something...

the form you pop up has several records, which you may change

you then want these changed record to update multiple
records in the recordset that your form is based on ... but
you have no way to link the data...

You need a way to relate the popup form to your main table.
BUT you are also breaking normalizaion rules in your main
table by storing the same information on several records...
the best way I can help you is to help you get your sata
properly structured -- then you would have no need to do this.

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access

remote programming and training
strive4peace2006 at yahoo.com


redthunder21 via AccessMonster.com wrote:
> Crystal,
>
> I tried your suggestions, but they didn't work. The table that I need to
> update is a table that Production Scans the bad inventory into and
> categorizes it. On my unbound form, I am asking the following:
>
> Category
> Damage Type
> Beginning Date
> Ending Date
> I also have a preview button and a print button on the form.
>
> This buttons run the TestQuery and I can see the results. Based on the
> results of the query, I want to update the main data tale with Moved = Yes,
> DateMoved = Now and Time Moved = Now.
>
> Is this unbound form really creating a temporary table? I have never used
> temporary tables.
>
> Thanks,
> Dawn
>
> strive4peace wrote:
>
>>Hi Dawn,
>>
>>Rather than trying to construct the SQL, use the Design view
>>of the query
>>
>>1. AddTables --> TestQuery, Tablename
>>(from the menu --> Query, Show Table)
>>
>>2. link the query to the table on the ID field -->
>>click on the ID field of the table and DRAG to the ID field
>>of the query and then let go of the mouse
>>
>>3. change the query to an UPDATE query
>>(from the menu --> Query, Update)
>>
>>4. put the fields on the grid to update
>>
>>drag the field from Tablename to the grid and fill in the
>>UpDateTo cell..
>>
>>field -->Moved
>>tablename --> Tablename
>>UpdateTo --> Yes
>>
>>field -->DateMoved
>>tablename --> Tablename
>>UpdateTo --> TestQuery.DateMoved
>>
>>field -->TimeMoved
>>tablename --> Tablename
>>UpdateTo --> TestQuery.TimeMoved
>>
>>then, Run!
>>
>>alternately, you could store DateTimeMoved (since Date and
>>Time can be stored together) and update that to Now()
>>
>>It seems that this is not the best logic to accomplish this
>>task... what is the criteria for TestQuery? Are you using a
>>temporary table?
>>
>>Have an awesome day
>>
>>Warm Regards,
>>Crystal
>>
>>MVP Microsoft Access
>>
>>remote programming and training
>>strive4peace2006 at yahoo.com
>>
>>
>>>I have an Unbound Form that uses a query to gather certain data. Once this
>>>data is int he query, I need to update another table. I want to update the 3

>>
>>[quoted text clipped - 16 lines]
>>
>>>Thanks,
>>>Dawn

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with update query and unbound combobox Rick Wright Microsoft Access 4 26th Mar 2010 12:12 AM
Update table with unbound combo box with sql string Travis Microsoft Access Form Coding 6 16th May 2008 12:52 AM
Update table field from a unbound form =?Utf-8?B?Um9ueQ==?= Microsoft Access 2 3rd Dec 2005 10:17 PM
Update Table from an unbound form =?Utf-8?B?SlQ=?= Microsoft Access VBA Modules 2 24th Aug 2005 02:00 AM
how do I update a field in a table thru a dlookup in a unbound txt =?Utf-8?B?SmVmZg==?= Microsoft Access Form Coding 1 14th Jun 2005 08:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:38 AM.