I have a form that allows a user to query info. On this form there are text boxes in which the user can add information to the record. Now, there is also a text box that computes a summation of a few manual entry text boxes. When I set the default value to 0 on one of the text boxes that is included in the summation, I can't even type in the first box that holds the unique query driver. The reason why I want to set the default value to 0 is because the user rarely uses these textboxes and would like to tab around them but also see the calculation. The calculation won't happen usless there is a value in all of the text boxes associated with the calculation. Is this possible. If you have any other questions please let me know. Thanks for the help.
Open the form in Design Mode. Right click goto properties. Scroll through the drop down box at the top that says detail, until you find 'Form'. Click on Form in the list. No goto the events tab. Find the OnLoad or Form Load (not sure which name it is ) Click the down arrow next to it. Click on Event Procedure Then click the little ... button. (That will take you into the VBA Editor).
Then make it look something like this.
Private Sub Yourformname_Load()
yourcontrol.value = 0
yourothercontrol.value = 0
'and so on and so forth
That way it sets the values after you load the form which will give the Primary Key a number if you have it on auto number.
Well the user types in a unique number on a form presses return, which then populates 5 text boxes. At this point he adds information to another 20 text boxes. Some of the 20 text boxes are involved in a calculation. I need to have two of these text boxes populated with a 0 after the user types in the unique number. I tried to set the default value to 0 on the property level but then the form won't let me type in the unique number. Hopefully that will help clarify.
I noticed you still had the Private sub stuff... if you put it in another Sub you have to remove the Private Sub that was originally on it. Like this is what it should look like...
Private Sub yourcontrolhere_AfterUpdate()
Daily_Lease_Charge.Value = 0
Other_Funds.Value = 0
If you change which control you are using to put the code in make sure you change the 'yourcontrolhere' text to that controls name. I hope I am not trying to explain something you already know. Sorry if that is the case.
Originally Posted by tjarvas
Maybe this will help.
Option Compare Database
Private Sub Button10_Click()
Dim strResp As String
If Me.Dirty = True Then
strResp = MsgBox("Do you want to save these changes?", vbYesNo, "Save?")
If strResp = vbNo Then
Private Sub Command149_Click()
On Error GoTo Err_Command149_Click
It's better to error on the side of explaining too much than not enough. I took out all of the sub stuff that didn't have anything between it. The form is tied to a query which is where to data comes from. If this code:
hrm. I gotta be missing something here... You say when the user inputs a 'Unique ID' they press 'Enter/Return' It is then and only then that the form queries the query? (dont know that I am explaining myself well).
I dont see any code that would make that text box do what you are saying it does.