Results 1 to 14 of 14
  1. #1
    Join Date
    Mar 2004
    Posts
    361

    Unanswered: Default Value won't allow query?

    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.

  2. #2
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Try to set the value to 0 using the Form_Load() function. Try that and let me know how it turns out.

    Thanks,
    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  3. #3
    Join Date
    Mar 2004
    Posts
    361
    Could you explain where I would but the Form_Load() function and what code is needed. Thanks!

  4. #4
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    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.

    Code:
    Private Sub Yourformname_Load()
        yourcontrol.value = 0
        yourothercontrol.value = 0
        'and so on and so forth
    End Sub
    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.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  5. #5
    Join Date
    Mar 2004
    Posts
    361
    I looked in the detail section but there was not on load, so I found it at the form level. Here is the code that I have right now.

    Private Sub Update_Details_Load()
    Daily_Lease_Charge.Value = 0
    Other_Funds.Value = 0
    'and so on and so forth
    End Sub

    The name of the form is Update Detail and the text box names are Daily Lease Charge and Other Funds.

    After I run the query, these two text boxes don't appear loaded with the value of 0.

  6. #6
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    What do you mean after you run the query. Maybe there is an aspect of this I am not understanding. Could you explain how your query and form relate?

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  7. #7
    Join Date
    Mar 2004
    Posts
    361
    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.

  8. #8
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    You need to put the following code in the after update of the UniqueID

    Code:
    Private Sub Update_Details_AfterUpdate()
        Daily_Lease_Charge.value = 0
        Other_Funds.value = 0
        'and so on and so forth
    End Sub
    Hope that helps.

    JS
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  9. #9
    Join Date
    Mar 2004
    Posts
    361
    I put

    Private Sub Update_Details_AfterUpdate()
    Daily_Lease_Charge.Value = 0
    Other_Funds.Value = 0
    'and so on and so forth
    End Sub

    in the after update property of Lease_Num which is the text box where the person types in the number. Unfortunatly, it did not populate the two text boxes. Shoot. Any other ideas?

  10. #10
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    Try putting it in the lostfocus of that text box. If that doesnt work try putting it in the after update of one of the 5 other populated fields.

    JS

    (Could you post all of the code for the whole form?)
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  11. #11
    Join Date
    Mar 2004
    Posts
    361
    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
    Me.Undo
    End If
    End If

    DoCmd.Close
    End Sub

    Private Sub Command149_Click()
    On Error GoTo Err_Command149_Click

    DoCmd.GoToRecord , , acNewRec
    DoCmd.GoToControl "Lease_Num"

    Exit_Command149_Click:
    Exit Sub

    Err_Command149_Click:
    MsgBox Err.Description
    Resume Exit_Command149_Click

    End Sub

    Private Sub Form_AfterUpdate()

    End Sub

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    End Sub

    Private Sub Form_Load()
    End Sub

    Private Sub Lease_Num_AfterUpdate()
    End Sub

    Just tell me where to put this and what property to try. I should be able to figure that out.

    Private Sub Update_Details_AfterUpdate()
    Daily_Lease_Charge.Value = 0
    Other_Funds.Value = 0
    'and so on and so forth
    End Sub

  12. #12
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    First I would say get rid of any of the Sub's that dont have any thing going on inside them.

    Second I am not seeing where the form is queried after the user inputs some data. (Is this on another form?)

    Third The code that needs to be inserted is only as follows...

    Code:
    Daily_Lease_Charge.Value = 0
    Other_Funds.Value = 0
    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...

    Code:
    Private Sub yourcontrolhere_AfterUpdate()
        Daily_Lease_Charge.Value = 0
        Other_Funds.Value = 0
    End Sub
    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.

    JS


    Quote 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
    Me.Undo
    End If
    End If

    DoCmd.Close
    End Sub

    Private Sub Command149_Click()
    On Error GoTo Err_Command149_Click

    DoCmd.GoToRecord , , acNewRec
    DoCmd.GoToControl "Lease_Num"

    Exit_Command149_Click:
    Exit Sub

    Err_Command149_Click:
    MsgBox Err.Description
    Resume Exit_Command149_Click

    End Sub

    Private Sub Form_AfterUpdate()

    End Sub

    Private Sub Form_BeforeUpdate(Cancel As Integer)

    End Sub

    Private Sub Form_Load()
    End Sub

    Private Sub Lease_Num_AfterUpdate()
    End Sub

    Just tell me where to put this and what property to try. I should be able to figure that out.

    Private Sub Update_Details_AfterUpdate()
    Daily_Lease_Charge.Value = 0
    Other_Funds.Value = 0
    'and so on and so forth
    End Sub
    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

  13. #13
    Join Date
    Mar 2004
    Posts
    361
    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:

    Daily_Lease_Charge.Value = 0
    Other_Funds.Value = 0

    is all that is needed, where shall I call these values?

  14. #14
    Join Date
    Mar 2004
    Location
    Nashville, TN
    Posts
    557
    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.

    JS

    I hope I explained it well?

    Have you ever thought about thinking on purpose?

    Jarvis Stubblefield
    Patriot Designs
    Web/Database Development and Consulting
    The-Patriot.net by Patriot Designs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •