G
Grizz
I have a unbound form, for doing calculations. The total output from user
input will show lowest price. The user will input bought price, at which the
user will click a button to add to tables. This is where I am having
problems with the coding.
Private Sub BtnBought_Click()
Dim dbLocal As Database
Dim rec As Recordset
Set dbLocal = CurrentDb()
Set rec = dbLocal.OpenRecordset("LoadInfoTbl", dbOpenDynaset)
With rec
.AddNew
!BuyDate = Me!TxtDate
!Weight = Me!TxtWeight
!Mileage = Me!TxtMileage
!Rate = Me!TxtRate
!BuyPrice = Me!TxtBuyPrice
.Update
.Close
End With
End Sub
I get an error on the button_click() highlighting the dbLocal as Database
I have tried to ommit this and set diretly in the rec =
currentDb.OpenRecordset Then i get a error on the dbOpenDynaset.
The form is Blank, no select statement to pull in tables no queries just
unbound text boxes and one combo box
the boxes are
txtDate ---------date()
txtMileage
txtRate
CmbChoice
txtYield
txtRate ..........Button will ouput buy Price
txtBuyPrice
txtTruck
txtBought ............... Button to add new record to three tables no the
fields are not the same for three tables.
input will show lowest price. The user will input bought price, at which the
user will click a button to add to tables. This is where I am having
problems with the coding.
Private Sub BtnBought_Click()
Dim dbLocal As Database
Dim rec As Recordset
Set dbLocal = CurrentDb()
Set rec = dbLocal.OpenRecordset("LoadInfoTbl", dbOpenDynaset)
With rec
.AddNew
!BuyDate = Me!TxtDate
!Weight = Me!TxtWeight
!Mileage = Me!TxtMileage
!Rate = Me!TxtRate
!BuyPrice = Me!TxtBuyPrice
.Update
.Close
End With
End Sub
I get an error on the button_click() highlighting the dbLocal as Database
I have tried to ommit this and set diretly in the rec =
currentDb.OpenRecordset Then i get a error on the dbOpenDynaset.
The form is Blank, no select statement to pull in tables no queries just
unbound text boxes and one combo box
the boxes are
txtDate ---------date()
txtMileage
txtRate
CmbChoice
txtYield
txtRate ..........Button will ouput buy Price
txtBuyPrice
txtTruck
txtBought ............... Button to add new record to three tables no the
fields are not the same for three tables.