By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,510 Members | 1,430 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,510 IT Pros & Developers. It's quick & easy.

Display table data in form text box

P: n/a
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
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"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
Nov 12 '05 #2

P: n/a
"James Fortune" <ja******@oakland.edu> wrote in message
news:a6**************************@posting.google.c om...
"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

That worked first time :) I had worked around it by placing another sub-form
based on tblVariables; it was a bit messy.

Thanks a ton, buddy. Great help :D

Craig
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.