"Craig M" <No**@mPlz.Thx> wrote in message news:<40***********************@news-text.dial.pipex.com>...
Hi,
Im pretty stuck. This is probably simple as, but I can't do it for the life
of me.
I have a form, frmRetailOrders with subform frmRetailOrderLine.
On the retailorders form, i simply want a text box to equal a "shipping"
rate, and another for the "VAT" rate. I am trying to pull these 2 values
from a table named "tblVariables", as the user needs to be able to change
them.
Any help would be appreciated.
Regards
Craig
Note: I'm just taking a guess at what you're trying to do.
I'm assuming tblVariables has only one record and that
the same value of ShippingRate and VATRate is used for
every customer until it gets changed. If this is not the
case then you'll need to omit the save part to keep the
same default values coming up. I couldn't tell if the user
being able to change them meant changing them in
tblVariables or changing them on the form for that order.
In your sub in frmRetailOrders put...
....current Dim statements
Dim MyDB As Database
Dim VarRS As Recordset
Dim strSQL As String
Set MyDB = CurrentDb
strSQL = "SELECT * FROM tblVariables;"
Set VarRS = MyDB.OpenRecordset(strSQL, dbOpenSnapshot)
VarRS.MoveFirst
txtShippingRate.Value = VarRS("ShippingRate")
txtVATRate.Value = VarRS("VATRate")
VarRS.Close
Set VarRS = Nothing
Set MyDB = Nothing
....
To save changed values back to tblVariables, create a new
command button called cmdSaveNewRates and in its OnClick
event paste the following code:
cmdSaveNewRates_Click()
Dim MyDB As Database
Dim VarRS As Recordset
Dim strSQL As String
Set MyDB = CurrentDb
strSQL = "SELECT * FROM tblVariables;"
Set VarRS = MyDB.OpenRecordset(strSQL, dbOpenDynaset)
VarRS.MoveFirst
VarRS.Edit
VarRS("ShippingRate") = txtShippingRate.Value
VarRS("VATRate") = txtVATRate.Value
VarRS.Update
VarRS.Close
Set VarRS = Nothing
Set MyDB = Nothing
MsgBox("ShippingRate and VATRate were updated successfully.")
End Sub
Post again explaining what you need to do in more detail if this
is not what you need.
James A. Fortune