Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jan 2005
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ComboBox default value (2002)

    Currently I have a combo box on a form the selects the terms for the order from a table of standard terms. The combo box works fine, but I want to set the default value to a field in the customers table called defaulterms. I have tried to enter the following SQL statement into the default value property, but it gives me the error: "The syntax of the subquery in this expression is incorrect.

    SELECT [TBL-Customers].TermsDefault FROM [TBL-Customers] WHERE ((([TBL-Customers].CustomerID)=[Forms]![FRM-Orders]![CustomerID]));

    Any suggestions? Thanks in advance.

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ComboBox default value (2002)

    You can't set a default value with a reference to a textbox that isn't filled when you create the new record.
    And you certainly cant use a select statement as a default property.
    In the After update event of your CustomerID textbox use a Dlookup function to enter your termsdefault.
    <pre>Private Sub CustomerID_AfterUpdate()
    If Me.NewRecord = True Then
    Me.TermsDefault = DLookup("TermsDefault", "TBL-Custommer", "CustomerID = " & Me.CustomerID)
    End If
    End Sub</pre>

    Replace Me.TermsDefault with Me. and the name of your textbox.
    If your CustomerID is a text field, use
    <pre>Me.TermsDefault = DLookup("TermsDefault", "TBL-Custommer", "CustomerID =' " & Me.CustomerID & "'")</pre>

    Francois

  3. #3
    New Lounger
    Join Date
    Jan 2005
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ComboBox default value (2002)

    That will do exactly what I want. I should have figured that out, but my lack of experience hinders me to think of that type of solution. Once again, you have been a big help. Thanks.

Posting Permissions

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