Hi Roy,
I forgot to confirm that if you write a second
'copy' of a record, the data will be saved with a
different ID.
I am not convinced that you need another table but
it is easy enough to add records from a button.
In the button's OnClick Event just add code like
this.
'~~~ Start of code ~~~~~~
Private Sub cmdAddRecord_Click()
'Append a new record to tblCostHistory
Dim SQL As String
On Error GoTo MyErr
'SQL = "INSERT INTO tblCostHistory (txtCOSTREF, txtCOSTDATE, txtCOST) "
SQL = "INSERT INTO tblCostHistory (txtCOSTREF, txtCOSTDATE, txtCOST) "
SQL = SQL & "SELECT " & Me.Strng & "," & Me.Dbl & "," & Me.Dbl2 & ";"
'SQL = SQL & "SELECT " & Me.txtCOSTREF & "," & Me.txtCOSTDATE & "," & Me.txtCOST & ";"
DoCmd.RunSQL SQL
MyExit:
Exit Sub
MyErr:
MsgBox "Err = " & Err & vbCrLf & Err.Description, , Me.Name & ".cmdAddRecord_Click"
Resume MyExit
Resume ' For debug
End Sub
'~~~ End of code ~~~~~~
View this message with ViewFixed Width Font selected
from the Options dropdown just above the message window.
Then when you copy the code it will be formatted so it
will be easier to read.
Hope that helps.
Regards, Clive.
--- In MS_Access_Professionals@yahoogroups.com, "jerseydiver62" <jerseydiver62@...> wrote:
>
>
> Thanks Clive,
>
> However, I really do need anoter table. All of the objects I have set up will only work properly if there is one occurance of an Item. The tblCostHistory will have many occurances.
>
> Roy Weiss
>
> --- In MS_Access_Professionals@yahoogroups.com, "Clive" <zctek@> wrote:
> >
> > Hi Jersey,
> >
> > You probably don't need another table. Just create
> > a new query to select the informatioon you want.
> > If you want the result displayed on a form then
> > use the query as the source for the new form.
> >
> > Hope that helps.
> >
> > Regards, Clive.
> >
> > --- In MS_Access_Professionals@yahoogroups.com, "jerseydiver62" <jerseydiver62@> wrote:
> > >
> > > Hi,
> > >
> > > I have a simple item database used to do a year-end inventory and pricing. There is a form I use to update the items with current price and last po# and date. I would like to take information from this for and add it to a different table to keep track of purchase history. The new table has the fields: AUTOID, ITEMID, COSTREF, COSTDATE, and COST.
> > >
> > > I would like to add a control button on the form to add the data from the form txtBoxes (txtITEMID, txtCOSTREF, txtCOSTDATE, txtCOST) to tblCostHistory, but I'm not sure how to code it. Also, the AUTOID in the table is an AutoNumber field to make sure there is no possibility of EXACT records. If I create a new record through the code in the form, will the AUTOID field still advance?
> > >
> > > Any thoughts or suggestions would be greatly appreciated.
> > >
> > > Thank you,
> > > JerseyDiver62
> > >
> >
>
Selasa, 04 September 2012
[MS_AccessPros] Re: Moving Select Data from a Form to a Table
__._,_.___
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar