Is it possible to create a form in MS Access 2007 that is not dependent on a recordset? I want to create a form that would just handle simple calculations, but would not rely on any data from the database.
This is the code I’ve tried to use, but when I run it I get a compile error “Method or data member not found.”
Private Sub btnCalc_Click()
Dim TotalCost As Integer
Dim DisposalCost As Integer
Dim CostRatio As Integer
TotalCost = txtTotalCost.Text
DisposalCost = txtDisposalCost.Text
CostRatio = TotalCost / DisposalCost
lblCostRatio.Text = CostRatio
End Sub
Is there something wrong with my code, or do I need to just create a winform to handle this?
Yes, it is perfectly possible. Do not refer to the
.textproperty, the text property is only available when a control has focus. if you must use a property – it is not required – use.value.For labels, you do indeed need the
.captionproperty.There are advantages in using a textbox for the answer, because you can set it to a function or a calculation. For example, you can set the control source to:
You can prevent the results textbox from being edited with the
lockedand / orenabledproperties. To ensure that the calculations is performed, you will need to set theformatproperty to a number or currency format.