Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476

    How to start in a particular Field?


    While working in a Form (in Form View) when I finish entering data into a Form & click on ‘New Record’ my cursor is in the field in which I was at in the previous Record. What is the trick to how can I have my cursor be in a particular field each time I choose a new Record?

    Thanks in advance!

  2. #2
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Are you using a command button for 'New Record?' If yes, then in your code for that button, add a line of code of SetFocus

    Here is the syntax: http://msdn.microsoft.com/en-us/libr...ffice.11).aspx

  3. #3
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    No, in faxct I can't get the Command Button to work/or I don't know how?

  4. #4
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    With your form open in design view. Add a Command button to the form. When the wizard opens click on cancel. Right click on the command button, select properties. Select Evensts. Select OnClick. Click on the ellipsis (...). Select Code Builder. VBA window will open. Copy and Paste the code below between the Sub line and the End line.

    Code:
    Private Sub Command20_Click()
    On Error GoTo Err_Command20_Click
    
    
    
    
        DoCmd.GoToRecord , , acNewRec
        Forms!frmTransactions.Payee.SetFocus
    
    
    Exit_Command20_Click:
        Exit Sub
    
    
    Err_Command20_Click:
        MsgBox Err.Description
        Resume Exit_Command20_Click
        
    End Sub
    The two items highlighted in red represent the form name and the field name (after the period) you wish to open and set the focus to. Change it to represent your table name and field name. Close the VBA window. Click on the Command Button and change the Caption to what ever you would like, ie. Add New Record.

    edit: My command button was named Command20, you will have to change yours to whatever Access assigns when you create it.

    Good luck.
    Alan

  5. #5
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    Why wouldn't my 'Use Control Wizard' work? In Design View I click on it & nothing Happens? Shouldn't I get a window with a list of commands?

  6. #6
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    Here's the problem. Either I can't find the Command Button or my Command button isn't working properly. In design view under Control, when I clink on the round circle with a black dot in the middle (isn't that the Command Button?) nothing happens If I click on the round circle with a black dot in the middle & then click any where on the Form it comes up as an 'Object.' What am I doing wrong here?

  7. #7
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    Ok, Dumb A** found the Command Button, Sorry. Let me play around with your Code. I'll get back to you.

  8. #8
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    It's not working. Here's what I have: Private Sub Command75_Click()
    On Error GoTo Err_Command75_Click


    DoCmd.GoToRecord , , acNewRec
    Forms!*Customers QuickInfo.CustomerID*.SetFocus

    Exit_Command75_Click:
    Exit Sub

    Err_Command75_Click:
    MsgBox Err.Description
    Resume Exit_Command75_Click

    End Sub

  9. #9
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Is your form actually named *Customers QuickInfo. and is your field named CustomerID*?

    First off, Because you have spaces in your table name, you need to wrap it in [square brackets] and if the * are not part of the names, then drop them from the code.
    It is not a good idea to have your table names or field names have spaces in them. A better convention is CustomersQuickInfo or Customers_QuickInfo.

    Look here for a paper on naming conventions. Will save you lots of heartache later.

    http://www.dhdurso.org/articles/acce...onventions.pdf

    Alan

  10. #10
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    Alan, Thanks for your time & effort, but it's just isn't working & becoming more of a headache. I learned something from you which I be mindful of in the future. More or less I basically learned (what little I know) Access by watching a few videos, trial & error, & mostly through you guys here on this forum. I always readily admit that I'm NOT a "programmer," my mind doesn't go that far/high & is probably my downfall in fully grasping the basics in databases. Anyway, I also learned/saw to always have/keep your field names as one word. However I don't believe anybody stressed to me to always have my 'Objects' be all one word as well. Maybe I'll keep playing around with the code, but I took out the * and placed brackets around the table name & the field name. Still not working. Instead of trying to make things easier/faster for me I'm getting way behind & not getting done what I had planned -- if you know what I mean. Thanks again Alan! Everyone here is so helpful & patient.

  11. #11
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    Alan, When I click on the command button this is how it looks:
    Private Sub Command125_Click()
    On Error GoTo Err_Command125_Click


    DoCmd.GoToRecord , , acNewRec
    Forms![Customers QuickInfo].CustomerID.SetFocus

    Exit_Command125_Click:
    Exit Sub The "Private Sub Command125_Click() " is highlighted in yellow. P.S. Why can't I hit "Return" anymore when typing on this Forum. When I Upgraded to Windows 8 I also went with IE 10 -- maybe that has something to do with it...?

  12. #12
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    The code looks ok. Run a compile and see if you get an error.

    I know nothing about IE 10 or Windows 8. Suggest you post a question of that ilk in another section of the forum and one of the mods should answer.

  13. #13
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    Please excuse my ignorance, what do you mean by, "Run a compile and see if you get an error.

    "

  14. #14
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    Open your vba window. open the module that holds the code we are discussing. Click on debug, and run the compile.

    Look at this reference on debugging code.

    http://www.cpearson.com/excel/debug.htm

  15. #15
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    [Click on debug, and run the compile] It's sort of not given me that option (although I have seen it in the past) I followed your instructions, On Error GoTo Err_Command125_Click this part is shaded & I get a compile error -- Label not found

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 10-16-2012, 04:19 PM
  2. Replies: 1
    Last Post: 05-22-2012, 10:46 AM
  3. Replies: 15
    Last Post: 04-06-2012, 10:57 AM
  4. How to start?
    By bergjes in forum Queries
    Replies: 8
    Last Post: 12-28-2011, 11:52 AM
  5. how can i start ?.
    By lavin80 in forum Access
    Replies: 1
    Last Post: 05-23-2009, 11:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums