Results 1 to 10 of 10
  1. #1
    New Lounger
    Join Date
    Sep 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form's fields (Access97)

    How do I in "Forms", after I use a control button "Add Record", have the cursor
    automatically move to a desired field for data entry? Presently, I have to move
    up to it to enter data.

    The second question, is it possible to have calculated fields change text color
    if they exceed a particular range? If so, how and where does one specify the
    desired range and then the putting of the two together? Presently I have the
    calculated fields working fine.

    All help is appreciated..

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Form's fields (Access97)

    If you add the new record using vba, you can include the line
    me!controlname.setfocus, where controlname is the name of the control you want to move to.

    I think you can do the same thing with a macro, but I forget.

    Access 2000 introduces conditional formatting exactly for what you want.
    In 97 you would have to write code in the after update event for the controls that contribute the data to the calulated field, ( and also in the oncurrent event for the form) to set the colour of the calculated field. This would work OK on a single form, but not on a continuous form because all occurrences of the field would all change at the same time.
    Regards
    John



  3. #3
    New Lounger
    Join Date
    Sep 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form's fields (Access97)

    John,

    Thank you for such a speedy reply. I won't get a chance to try it till Wednesday at work, I appreciate it very much, I have been struggling with for a couple of days now.

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Form's fields (Access97)

    Your question:
    << How do I in "Forms", after I use a control button "Add Record", have the cursor
    automatically move to a desired field for data entry? >>

    What I would do here, is while in design view of the form, seelct View and Tab Order, this way you can specify the order of the controls on the form.

    As to your second question, John's idea is ok for this.

    HTH
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Form's fields (Access97)

    I agree that setting the tab order would usually do the same job. There are times however when I want to set the focus to a control that is not first in the tab order, and setfocus allows you to put the focus anywhere you like.
    Sometimes you can put values into some fields using code, and so you want to set the focus to the first blank field.
    Regards
    John



  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Form's fields (Access97)

    Watch out for code that tries to use setfocus on the control that already has the focus though.
    Charlotte

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Form's fields (Access97)

    I wasn't aware of this problem.
    I have just been trying it out, and it seemed to just ignore the setfocus command, and move the next control.
    Is this all that happens or does it cause more serious problems?
    Regards
    John



  8. #8
    New Lounger
    Join Date
    Sep 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form's fields (Access97)

    Thanks everyone for your help, I wish I had of thought of using this before.
    The setfocus worked great for moving the cursor up to the desired field. Thanks..... I had previously tried the tab order but the cursor would stay on the "Add Record" button.
    I was also able to get the data to change text as desired using code, but now I keep getting -" Run-time Error "13" - Type Mismatch". I am looking at one field and upon it's change, calculating to a "%" in another field. Is this my problem?

  9. #9
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Form's fields (Access97)

    Can you post the code you are using.
    Not sure what you mean by " calculating to a "%" in another field" ?
    Regards
    John



  10. #10
    New Lounger
    Join Date
    Sep 2002
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Form's fields (Access97)

    Private Sub Slurry_Weight_AfterUpdate()
    Dim lngRed AS Long, lngWhite As Long
    Dim pct_slurry As String

    Me.Slurry.Enabled = True
    Me.Slurry.SetFocus
    pct_slurry=Me.Slurry.Text
    Me.Slurry_Weight.SetFocus
    Me.Slurry.Enabled=False

    lngRed= RGB(255, 0 ,00
    lngWhite=RGB(255, 255, 255)
    If CSng(Left$(pct_slurry, Len(pct_slurry) - 1)) < 12 then (this is where the error is.)
    Me.Slurry.ForeColor = lngRed

    I did not include all the script, but hopefully this helps. Thanks in advance.

Posting Permissions

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