Re: Debug/Compile Error

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



These were my previous instructions:

1. Open the form in Design View

2. On the main menu bar go to View | Properties.
This will bring up the form's properties list.
(The dialog box should say "Form" in the upper left corner)

3. On the "All" or "Event" tabs look for an line that says
"On Current"

4. Single click on that line itself and a little arrow will appear at
the right side of this line along with a little button that has three
dots on it (...). Click that button with the three dots and a small
dialog prompt will appear. Select the option that says "Code
Builder" and click OK to go to the code window for this form.

5. Your cursor should be in between these two lines:

Private Sub Form_Current()

End Sub

6. Copy and paste this code *in between* those two lines:

If Me.NewRecord = True Then
Me.MyFirstControlNameHere.SetFocus
End If

7. Now where I have the long word MyFirstControlNameHere
you will need to *replace* that part with the actual name of the
form control you want the cursor to be on for a new record. So
if, for example your first form control is called FirstField change the
code to this:

If Me.NewRecord = True Then
Me.FirstField.SetFocus
End If

Follow me?

8. Compile the code (Debug | Compile from menu bar here)

9. Save and close the form and then test. That's it.

Did you change the code I gave to reflect the name of your actual
first code?

Did you type that code directly onto the form's propertie's list?

Can you show me the code you have right now in the form's current
event? Open the form in Design View and then go to the code window
by selecting View | Code form the menu bar. Find the Current event
and post here what you have there right now.

--
Jeff Conrad
Access Junkie
Bend, Oregon

"faxylady" wrote in message:
news:785992F8-FAF5-4319-B0BB-E5B11C1DE712@xxxxxxxxxxxxxxxx

> This message is directed to Jeff Conrad.
>
> Last week you answered a question for me regarding the cursor not appearing
> on the first line of my form after the 'add new record' button was clicked.
> Following is the entire thread:
>
> Cursor will not start in first field box in Access Database Forms
>
>
> Question
>
>
>
> I put an 'add new record' button on my forms. When I click it to add new
> data, I also have to click in the first field to begin. Why won't the cursor
> automatically appear in the first field after the 'add new record' button is
> clicked?
>
>
>
> Bob Howard 5/31/2005 5:32 PM PST
>
>
>
>
>
> You need to put a setfocus method in the onclick event to move the focus
> off the button you just clicked and onto the data field. Access only moves
> the focus when either the user clicks on something or the program moves it.
> "faxylady" <faxylady@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message Click to
> show or hide original message or reply text.
>
>
> faxylady 5/31/2005 8:09 PM PST
>
>
>
>
>
> Thank you. Please tell me how to do this as I am not advanced enough to
> know what you are talking about. Be explicit with instructions.
>
>
> Jeff Conrad 5/31/2005 5:35 PM PST
>
>
>
>
>
> "faxylady" wrote in message:
> news:F80DEFAD-87E3-4CE3-81EE-35380F6AB896@xxxxxxxxxxxxxxxx > I put an 'add
> new record' button on my forms. When I click it to add new > data, I also
> have to click in the first field to begin. Why won't the cursor >
> automatically appear in the first field after the 'add new record' button is
> > clicked? On the Current event of the form, test to see if you are on a new
> record. If you are, set the focus to whatever control you wish. Something
> like so: Private Sub Form_Current() If Me.NewRecord = True Then
> Me.MyFirstControlNameHere.SetFocus End If End Sub -- Jeff Conrad Access
> Junkie Bend, Oregon
>
>
> Thank you. Please give more explicit instructions as I am a novice to
> Access. "On the Current event of the form, test to see if you are on a new
> record." Tell me how to do this.
>
> Jeff Conrad 5/31/2005 8:52 PM PST
>
>
>
>
>
> "faxylady" wrote in message:
> news:2F745085-C451-47F1-B7C0-6C446A9395AB@xxxxxxxxxxxxxxxx > Thank you.
> Please give more explicit instructions as I am a novice to > Access. "On the
> Current event of the form, test to see if you are on a new > record." Tell me
> how to do this. 1. Open the form in Design View 2. On the main menu bar go to
> View | Properties. This will bring up the form's properties list. (The dialog
> box should say "Form" in the upper left corner) 3. On the "All" or "Event"
> tabs look for an line that says "On Current" 4. Single click on that line
> itself and a little arrow will appear at the right side of this line along
> with a little button that has three dots on it (...). Click that button with
> the three dots and a small dialog prompt will appear. Select the option that
> says "Code Builder" and click OK to go to the code window for this form. 5.
> Your cursor should be in between these two lines: Private Sub Form_Current()
> End Sub 6. Copy and paste this code *in between* those two lines: If
> Me.NewRecord = True Then Me.MyFirstControlNameHere.SetFocus End If 7. Now
> where I have the long word MyFirstControlNameHere you will need to *replace*
> that part with the actual name of the form control you want the cursor to be
> on for a new record. So if, for example your first form control is called
> FirstField change the code to this: If Me.NewRecord = True Then
> Me.FirstName.SetFocus End If Follow me? 8. Compile the code (Debug | Compile
> from menu bar here) 9. Save and close the form and then test. That's it. --
> Jeff Conrad Access Junkie Bend, Oregon Click to show or hide original message
> or reply text.
>
>
>
> I copied and pasted the code as instructed. At instruction #8, I clicked
> Debug from the menu. Compile was greyed out. Then I received an error:
> Compile Error, Expected: Expression. The code I pasted in was highlighted in
> red.
>
>
> Please tell me what to do now.
>


.



Relevant Pages

  • Debug/Compile Error
    ... Cursor will not start in first field box in Access Database Forms ... Me.MyFirstControlNameHere.SetFocus End If End Sub -- Jeff Conrad Access ... Please give more explicit instructions as I am a novice to ...
    (microsoft.public.access.forms)
  • Re: Which is the strangest?
    ... the instructions did not spell out "Expect it to break - it will not ... There is a deep groove in the top of the bar. ... "Fill plain cup with room temperature water. ... "A) Place tube on desk with green end up. ...
    (rec.arts.sf.science)
  • Re: branch prediction optimization
    ... be a useful optimization otherwise why have the special instructions. ... Is there a way to tell the compiler that the 'if ' will ... you will take the foo() direction 25% of the time ... and bar() the other 75%. ...
    (comp.unix.programmer)
  • Re: Adding a Tip in Word
    ... If creating a template you can draw attention to the status bar help by ... Word MVP web site http://word.mvps.org ... you can enter your instructions as the default ...
    (microsoft.public.word.docmanagement)
  • Re: FAQ Topic - I have window.status="Moomin"; why doesnt the statusbar change? (2009-11-
    ... evidence that the status bar is a good place ... Where the status bar is present, the browser may be configured to ... So the script may be able to set status bar text, and the FAQ would be ... It is possible that the page contains instructions to read the status ...
    (comp.lang.javascript)