on dirty

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i hav a field which is in subform. i'm named it as location. when user change
the location and i want to know and i want the record to keep it in a table.
i want to know when the user change the location n where they put the things
now. what i can do? thanks!
 
i hav a field which is in subform. i'm named it as location. when user change
the location and i want to know and i want the record to keep it in a table.
i want to know when the user change the location n where they put the things
now. what i can do? thanks!

Use code in the Location control's AfterUpdate event. Since I don't
clearly understand WHAT you wantt to happen ("i want the record to
keep it in a table" is pretty ambiguous!) I'm not sure what that code
would be - but that is at least the appropriate event!

John W. Vinson[MVP]
 
sorry, cos my english is not so good until u cant understand wat i'm saying.
i've create a form that is for user to change the location when they changing
the place for the things. that is direct field from the table A. but i want
keep the record for location when they change the location in table B. just
like a history. cos i want to review back when they change the location when
the problem comes out. actually can like using query append. but i want when
location hav changing then jus append to table B. wat should i do?
 
sorry, cos my english is not so good until u cant understand wat i'm saying.
i've create a form that is for user to change the location when they changing
the place for the things. that is direct field from the table A. but i want
keep the record for location when they change the location in table B. just
like a history. cos i want to review back when they change the location when
the problem comes out. actually can like using query append. but i want when
location hav changing then jus append to table B. wat should i do?

Run the Append query from the AfterUpdate event of the Location
control on the form. You can either use a parameter query referencing
the form, or (probably better) build the SQL string in code. Something
like

Private Sub cboLocation_AfterUpdate()
Dim strSQL As String
Dim db As DAO.Database
Dim qd As DAO.Querydef
On Error Goto Proc_Error
strSQL = "INSERT INTO ChangeLog (OldLoc, NewLoc, UserID, When)" _
& " VALUES('" cboLocation.OldValue & _
& "', '" & cboLocation.Value & _
& "', '" & CurrentUser() & _
& "', #" & Now & "#);"
Set db = CurrentDb
Set qd = db.CreateQuerydef("", strSQL)
qc.Execute dbFailOnError
Proc_Exit: Exit Sub
Proc_Error:
<put in error handling code>
End Sub

John W. Vinson[MVP]
 
thanks John. i'm stil hav a question that, is it i really need using SQL? can
i type in microsft vb? thanks for ur helping n patience!
 
thanks John. i'm stil hav a question that, is it i really need using SQL? can
i type in microsft vb? thanks for ur helping n patience!

My suggestion was to use Access VBA (not VB, which is a separate
product) to actually construct an Access Query. The language of
queries is SQL - Access uses a dialect of SQL, and again, I'm not
suggesting that you need to use the SQL/Server product.

Since I do not know anything about your table structure or field
names, I've posted an example of how this might be done. You will need
to adapt the suggested code to your own database, using your own field
names.

There are other ways to do it, not involving queries (open a Recordset
and use the AddNew method) but queries are often more efficient. If
you need help with the code, please post the name and fieldnames of
the table into which you're inserting data, and some idea of where the
data to be inserted should come from.

John W. Vinson[MVP]
 
thanks John! i'm hav two table. one is call "time sheet" and one is call
"daily record". i'm create a form that is using "time sheet" table. inside
"time sheet table have few field, that is "item", "qty", "location", "date"
and "packing qty". user wil use this form to change the data such like
"location" and "qty". once they want to change qty then they will key into
the field "packing qty" and the data wil append to "daily record" table. the
qty for that item also wil be change in the "time sheet" table. now, i also
want to do the same things for the location. if the user change the location
from here to there such like from "1a" to "1b", then i want the data also
append to "daily record" table. can make it? it is also want to change in the
"time sheet" table. can? thanks!
 
Back
Top