Results 1 to 8 of 8

Thread: Error in code

  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Unanswered: Error in code

    hi guys I have a combo box that updates 2 others. (cascading combo box) the combo that updates the others has codes like 1a, 1b..etc and when you chooose one of them the values related to those codes updates the other combo boxes. but I'm getting an error message and I'm not sure why. Can anyone tell me if somethign is wrong with this code??


    Private Sub ServicesCode_AfterUpdate()

    Me.StateCategory = Me.ServicesCode.Column(2)
    Me.StateCategory.SetFocus
    Me.StateCategory.Dropdown
    Me.StateServices = Me.ServicesCode.Column(3)
    Me.StateServices.SetFocus
    Me.StateServices.Dropdown
    Me.ServicesCode.SetFocus





    End Sub

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by desireemm View Post
    I'm getting an error message and I'm not sure why.
    Me either. What is the message? What line triggers it?

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Quote Originally Posted by pootle flump View Post
    Me either. What is the message? What line triggers it?
    don't be coy poots
    the error message is beacue there is a run time error on the code

    as to what the error message is, and when its generated, like you is a mystery to me

    memo to self:
    must dig out the crystal ball to be in a position to forsee what the error is in future
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Me.StateCategory = Me.ServicesCode.Column(2)
    Me.StateCategory.SetFocus
    Me.StateCategory.Dropdown
    Me.StateServices = Me.ServicesCode.Column(3)
    Me.StateServices.SetFocus
    Me.StateServices.Dropdown
    Me.ServicesCode.SetFocus


    A 'possibility' is the misuse of the dot (.). Hard to say since the error wasn't stated but....

    Me!StateCategory = Me.ServicesCode.Column(2)
    Me.StateCategory.SetFocus
    Me.StateCategory.Dropdown
    Me!StateServices = Me.ServicesCode.Column(3)
    Me.StateServices.SetFocus
    Me.StateServices.Dropdown
    Me.ServicesCode.SetFocus


    Notice ! is not the same as .
    (!!!!!..... to emphasis). ! means the value of the field while . means the field/control itself.

    me.SomeFieldName = "some value" is NOT necessarily the same as me!SomeFieldName = "some value" (although MSAccess often lets you get away with this, get in the correct habit of using ! and . when appropriate)

    (Or remember that you can't set the focus to a field which already has the focus.) Or that you can utilize me.StateServices.Dropdown in the GotFocus event of the field as well.
    Last edited by pkstormy; 04-06-10 at 08:58.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    I'm trying to figure out the object of these bold lines

    Me.StateCategory.SetFocus
    Me.StateCategory.Dropdown
    Me!StateServices = Me.ServicesCode.Column(3)
    Me.StateCategory.SetFocus
    Me.StateCategory.Dropdown
    Me!StateServices = Me.ServicesCode.Column(3)
    Me.StateServices.SetFocus
    Me.StateServices.Dropdown
    Me.ServicesCode.SetFocus


    Access is going to execute them, one after the other, and the only thing accomplished will be that the focus will be on the Combobox they were called from. I suspect on most PCs this will happen so fast you won't even realize that the focus or dropdown has occurred.

    As to the error, are all control names spelled correctly? The code indicates that there are at least 4 columns; is this true?

    And lastly, why would you assign a single value to a Combobox, as is being done here?

    Knowing the error message really would help here!
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789
    I apologize for not posting the error message, mistake on my part
    Its a compiler message it says that Method or Data Member not found. I so sorry guys thanks for your help

  7. #7
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    C'mon Desi - you've been a member for years. Help us to help you.
    Quote Originally Posted by pootle flump View Post
    Me either. What is the message? What line triggers it?

  8. #8
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789
    Never mind Pootle thank you
    I shouldnt posted the problem. I did the samething on another form that has cascading combo boxes and theres no errors

Posting Permissions

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