Default valus for subform

B

Bob Danehy

When opening a form, I want to be prompted to enter
default values for 2 fields in a subform. These values
would be used as long as the form is open. I have not
found a way to do this. I am using Access 97. Can anyone
help me?
 
T

Tony Vrolyk

I am guessing you want different 'default values' each time you want to open
the form. Be careful how you refer to them, "Default values" usually refer
to a property setting for the control (or a field in a table) which is true
anytime the form or table is opened.

Anyway.
Declare variables as needed in the declaration section of the underlying
module.

Dim strSomeString as String

'Then OnOpen of the form, if the variable is empty ask for a value
'Otherwise set control to = the variable

Private Sub Form_Open(Cancel As Integer)
If strSomeString <> "" Then
strSomeString = InputBox("Please Enter A Value", , "Default Value")
Else
Me.TextBox = strSomeString
End If
End Sub



This is kinda off the top of my head, but should get you started
Tony
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top