retrieving data from last entry AfterInsert

  • Thread starter Thread starter tracktraining
  • Start date Start date
T

tracktraining

Hi all,

I am trying to retrieve the data from the last entry so I can assign the
data to other tables. I don't know anything about visual basic.

What code should I write in the AfterInsert event procedure of a Form in MS
Access in order to retrieve fields of the last record entered through the Form

This is what my friend has so far:

Private Sub Form_AfterInsert()
Dim db As Database
SQLStmt = "SELECT * FROM EmployeeTable WHERE"
MsgBox ([Form_Employee Information].CurrentRecord)
Set db = CurrentDb

End Sub

Please help.
 
That would not be reliable.
If you need values from the record you just entered to use for other
purposes, use the Form Before Update event and assign the values of each
control to the control's Tag property. You can then refer to the tag
property to retrieve the values.
 
Thanks Klatuu.

So I just tagged each control. But I don't know what to do next.

Tables:
DocTable: DocID(PK), DocName, Revision(PK), DateAuthorized
EmpDocStatusTable: EmpEmail(PK), DocID(PK), Status, Revision
EmployeeTable: EmpEmail(PK), EmpName, JobFun, EmpDeptName
JobFunTable: JobFun(PK), JobFunDes, DocID (PK), DocName

Forms:
Document Table
Employee Information
Job Function Information

Example:
I want to take the information I just entered into the Employee forms and
automatically populate the document table and the job function table.

I have this:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Forms![Employee Information]!EmpName.Properties(5).Name

End Sub

Am I in the right direction? Can any one direct me to a source that I can
read up on how to do this? Or can anyone who me how this is done? Is there a
better way to do this? I don't know anything about VB and am just reading
about the software for the past 2 days.

thanks very much.... so confused.


--
Learning


Klatuu said:
That would not be reliable.
If you need values from the record you just entered to use for other
purposes, use the Form Before Update event and assign the values of each
control to the control's Tag property. You can then refer to the tag
property to retrieve the values.
--
Dave Hargis, Microsoft Access MVP


tracktraining said:
Hi all,

I am trying to retrieve the data from the last entry so I can assign the
data to other tables. I don't know anything about visual basic.

What code should I write in the AfterInsert event procedure of a Form in MS
Access in order to retrieve fields of the last record entered through the Form

This is what my friend has so far:

Private Sub Form_AfterInsert()
Dim db As Database
SQLStmt = "SELECT * FROM EmployeeTable WHERE"
MsgBox ([Form_Employee Information].CurrentRecord)
Set db = CurrentDb

End Sub

Please help.
 
No, it would be:
Me.EmpName.Tag = Me.EmpName

Since I know nothing about your form, how it works, or when you want to
create the records, I can't give you much detail. But, once you have
captured the values, you can either use an Append query that references the
control on your form or you can create an SQL statement in VBA and create the
records.
--
Dave Hargis, Microsoft Access MVP


tracktraining said:
Thanks Klatuu.

So I just tagged each control. But I don't know what to do next.

Tables:
DocTable: DocID(PK), DocName, Revision(PK), DateAuthorized
EmpDocStatusTable: EmpEmail(PK), DocID(PK), Status, Revision
EmployeeTable: EmpEmail(PK), EmpName, JobFun, EmpDeptName
JobFunTable: JobFun(PK), JobFunDes, DocID (PK), DocName

Forms:
Document Table
Employee Information
Job Function Information

Example:
I want to take the information I just entered into the Employee forms and
automatically populate the document table and the job function table.

I have this:

Private Sub Form_BeforeUpdate(Cancel As Integer)

Forms![Employee Information]!EmpName.Properties(5).Name

End Sub

Am I in the right direction? Can any one direct me to a source that I can
read up on how to do this? Or can anyone who me how this is done? Is there a
better way to do this? I don't know anything about VB and am just reading
about the software for the past 2 days.

thanks very much.... so confused.


--
Learning


Klatuu said:
That would not be reliable.
If you need values from the record you just entered to use for other
purposes, use the Form Before Update event and assign the values of each
control to the control's Tag property. You can then refer to the tag
property to retrieve the values.
--
Dave Hargis, Microsoft Access MVP


tracktraining said:
Hi all,

I am trying to retrieve the data from the last entry so I can assign the
data to other tables. I don't know anything about visual basic.

What code should I write in the AfterInsert event procedure of a Form in MS
Access in order to retrieve fields of the last record entered through the Form

This is what my friend has so far:

Private Sub Form_AfterInsert()
Dim db As Database
SQLStmt = "SELECT * FROM EmployeeTable WHERE"
MsgBox ([Form_Employee Information].CurrentRecord)
Set db = CurrentDb

End Sub

Please help.
 
Back
Top