SendKeys 
Author Message
 SendKeys

I'm trying to do the most basic action using VBA.  I have
a report that I want to generate, but I want to bypass a
prompt that comes up, so I want to automate the "Enter"
key before the report opens.

The report is opened via a label box that is hyperlinked
to the Report object.  So, I go to the "OnClick" selection
on the label properties and right this code behind the
form....

Private Sub lblreportlink_Click()

SendKeys {ENTER}, True

End Sub

I get Compile Error saying "Invalid character".  This is
exactly what the help files are telling me to do and its
not working.  

Thanks ahead of time for your help.....

Matt



Sun, 02 Oct 2005 23:18:33 GMT  
 SendKeys
Help should be saying that it expects a STRING as the first parameter.  Try:

Private Sub lblreportlink_Click()

   SendKeys "{ENTER}", True

End Sub

BUT it is normally a BAD thing to use SendKeys.  There are timing issues and
side effects.

What prompt are you trying to avoid?  Perhaps there is a better way of handling
the situation.

Quote:

> I'm trying to do the most basic action using VBA.  I have
> a report that I want to generate, but I want to bypass a
> prompt that comes up, so I want to automate the "Enter"
> key before the report opens.

> The report is opened via a label box that is hyperlinked
> to the Report object.  So, I go to the "OnClick" selection
> on the label properties and right this code behind the
> form....

> Private Sub lblreportlink_Click()

> SendKeys {ENTER}, True

> End Sub

> I get Compile Error saying "Invalid character".  This is
> exactly what the help files are telling me to do and its
> not working.

> Thanks ahead of time for your help.....

> Matt



Mon, 03 Oct 2005 00:10:19 GMT  
 SendKeys
Hi John,

I know that SendKeys is not usually the first choice -
thanks for the heads-up.  

The prompt I'm trying to avoid is from a formula from a
query that I've created.  The formula is below...

Shift: IIf([All Agents].[Position / Shift] Is Null,"No
Shift Specified" & " -- " & ([All Agents].[Employee
Name]),Left([All Agents].[Position / Shift],1))

The [All Agents].[Position / Shift] contains shifts
like "FT1, FT2, PT2, PT4" so I want to capture only the
first letter and if the value is null, then I want it to
pull the name of the person who's shift value is null.  
When I do the query, it doesn't prompt, but when I
generate the report from the query, it prompts me for that
field.  I simply hit "ENTER" and it give me the info
correctly.  

I'm using Access97, so I don't know if this is something
that I can avoid - I think Access is just getting confused
somewhere.  The fact that it doesn't work on the query
leads me to believe that there's not much else I can to
get around it.  

I'm sure you have a couple suggestions, however...;-)

m

Quote:
>-----Original Message-----
>Help should be saying that it expects a STRING as the

first parameter.  Try:
Quote:

>Private Sub lblreportlink_Click()

>   SendKeys "{ENTER}", True

>End Sub

>BUT it is normally a BAD thing to use SendKeys.  There

are timing issues and
Quote:
>side effects.

>What prompt are you trying to avoid?  Perhaps there is a

better way of handling
Quote:
>the situation.


>> I'm trying to do the most basic action using VBA.  I
have
>> a report that I want to generate, but I want to bypass a
>> prompt that comes up, so I want to automate the "Enter"
>> key before the report opens.

>> The report is opened via a label box that is hyperlinked
>> to the Report object.  So, I go to the "OnClick"
selection
>> on the label properties and right this code behind the
>> form....

>> Private Sub lblreportlink_Click()

>> SendKeys {ENTER}, True

>> End Sub

>> I get Compile Error saying "Invalid character".  This is
>> exactly what the help files are telling me to do and its
>> not working.

>> Thanks ahead of time for your help.....

>> Matt
>.



Mon, 03 Oct 2005 02:20:28 GMT  
 SendKeys
I read this as if your field is called "[Position / Shift]". Now that is asking for trouble: spaces and a special character in a
fieldname.

I would advise to get rid of all spaces in every table\fieldname. Maybe Access indeed gets confused, just because this is not good
coding practice....

Jacques

Hi John,

I know that SendKeys is not usually the first choice -
thanks for the heads-up.

The prompt I'm trying to avoid is from a formula from a
query that I've created.  The formula is below...

Shift: IIf([All Agents].[Position / Shift] Is Null,"No
Shift Specified" & " -- " & ([All Agents].[Employee
Name]),Left([All Agents].[Position / Shift],1))

The [All Agents].[Position / Shift] contains shifts
like "FT1, FT2, PT2, PT4" so I want to capture only the
first letter and if the value is null, then I want it to
pull the name of the person who's shift value is null.
When I do the query, it doesn't prompt, but when I
generate the report from the query, it prompts me for that
field.  I simply hit "ENTER" and it give me the info
correctly.

I'm using Access97, so I don't know if this is something
that I can avoid - I think Access is just getting confused
somewhere.  The fact that it doesn't work on the query
leads me to believe that there's not much else I can to
get around it.

I'm sure you have a couple suggestions, however...;-)

m

Quote:
>-----Original Message-----
>Help should be saying that it expects a STRING as the

first parameter.  Try:
Quote:

>Private Sub lblreportlink_Click()

>   SendKeys "{ENTER}", True

>End Sub

>BUT it is normally a BAD thing to use SendKeys.  There

are timing issues and
Quote:
>side effects.

>What prompt are you trying to avoid?  Perhaps there is a

better way of handling
Quote:
>the situation.


>> I'm trying to do the most basic action using VBA.  I
have
>> a report that I want to generate, but I want to bypass a
>> prompt that comes up, so I want to automate the "Enter"
>> key before the report opens.

>> The report is opened via a label box that is hyperlinked
>> to the Report object.  So, I go to the "OnClick"
selection
>> on the label properties and right this code behind the
>> form....

>> Private Sub lblreportlink_Click()

>> SendKeys {ENTER}, True

>> End Sub

>> I get Compile Error saying "Invalid character".  This is
>> exactly what the help files are telling me to do and its
>> not working.

>> Thanks ahead of time for your help.....

>> Matt
>.



Mon, 03 Oct 2005 04:37:13 GMT  
 SendKeys
If the query works and gives you the expected values, then your query is
probably not the problem.

There is something in the report that is causing the problem.  Probably, you
have a field name misspelled on a textbox, or in the sorting and grouping dialog
or in a filter property.  This can be hard to track down remotely.

Another word of advice, you are evidently storing two types of information in
one field [Position / Shift] seems to have information on whether an employee is
Full Time or Part Time and which shift 1 or 2 they are working.  You might want
to look into separating the two items into two fields.

Quote:

> Hi John,

> I know that SendKeys is not usually the first choice -
> thanks for the heads-up.

> The prompt I'm trying to avoid is from a formula from a
> query that I've created.  The formula is below...

> Shift: IIf([All Agents].[Position / Shift] Is Null,"No
> Shift Specified" & " -- " & ([All Agents].[Employee
> Name]),Left([All Agents].[Position / Shift],1))

> The [All Agents].[Position / Shift] contains shifts
> like "FT1, FT2, PT2, PT4" so I want to capture only the
> first letter and if the value is null, then I want it to
> pull the name of the person who's shift value is null.
> When I do the query, it doesn't prompt, but when I
> generate the report from the query, it prompts me for that
> field.  I simply hit "ENTER" and it give me the info
> correctly.

> I'm using Access97, so I don't know if this is something
> that I can avoid - I think Access is just getting confused
> somewhere.  The fact that it doesn't work on the query
> leads me to believe that there's not much else I can to
> get around it.

> I'm sure you have a couple suggestions, however...;-)

> m

> >-----Original Message-----
> >Help should be saying that it expects a STRING as the
> first parameter.  Try:

> >Private Sub lblreportlink_Click()

> >   SendKeys "{ENTER}", True

> >End Sub

> >BUT it is normally a BAD thing to use SendKeys.  There
> are timing issues and
> >side effects.

> >What prompt are you trying to avoid?  Perhaps there is a
> better way of handling
> >the situation.


> >> I'm trying to do the most basic action using VBA.  I
> have
> >> a report that I want to generate, but I want to bypass a
> >> prompt that comes up, so I want to automate the "Enter"
> >> key before the report opens.

> >> The report is opened via a label box that is hyperlinked
> >> to the Report object.  So, I go to the "OnClick"
> selection
> >> on the label properties and right this code behind the
> >> form....

> >> Private Sub lblreportlink_Click()

> >> SendKeys {ENTER}, True

> >> End Sub

> >> I get Compile Error saying "Invalid character".  This is
> >> exactly what the help files are telling me to do and its
> >> not working.

> >> Thanks ahead of time for your help.....

> >> Matt
> >.



Mon, 03 Oct 2005 06:20:06 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. SendKeys problem - datagrid app. shuts down after updating by sendkeys

2. Concerning Sendkeys bug

3. SendKeys & the numeric keypad - revised

4. SendKeys & the numeric keypad

5. Compact SendKeys

6. Sendkeys

7. Sendkeys

8. SendKeys

9. Sendkeys replacement?

10. SendKeys question

11. SendKeys Syntax

12. SendKeys

 

 
Powered by phpBB® Forum Software