send Keys problem

G

Guest

I have a database that when my users open a form a macro runs to put the
focus in a box called "Lot Number". The form is named "ETFA". Once the focus
is in the box the macro uses the send keys function {down} to select the
number in the box. When the form first opens the focus is set correctly, but
the send keys function does not work. I can close the form and immediatly
reopen it and the send keys function works. What is wrong and can I do this
in another way other than the send keys function?
 
S

strive4peace

Instead of using SendKeys, simply assign the value to the combo

me.combo_controlname = value


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
G

Guest

I can't assign a value to this text box because it changes every time the
form opens. This is a number that increases by 1 each time.
 
S

strive4peace

Hi Halo,

if what you want it the first item in the list

'list has heading row
me.controlname = [controlname].[ItemData](1)

'list does not have heading row
me.controlname = [controlname].[ItemData](0)

do this on the LOAD event, not the Open event...

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 
G

Guest

I don't think that will work either. This lot number is not in a list the
database does a calculation to generate this number. The lot number is not
part of a list. Our lot numbers are generated through a query function:
Max Of Sample ID: Max([Sample Registration].[Sample ID])+1

is there code that I can put in there that will put the focus in the list
box (called Sample ID) and simulate a mouse click in that box? You know when
you click in a list box it turns black to show it is selected, that is what I
need to happen automatically. I am sorry for the trouble, I am still learning
as I go.

strive4peace" <"strive4peace2006 at yaho said:
Hi Halo,

if what you want it the first item in the list

'list has heading row
me.controlname = [controlname].[ItemData](1)

'list does not have heading row
me.controlname = [controlname].[ItemData](0)

do this on the LOAD event, not the Open event...

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
I can't assign a value to this text box because it changes every time the
form opens. This is a number that increases by 1 each time.

:
 
S

strive4peace

Hi Halo,

I am a bit confused... clicking on an entry is the same as
selecting it, which is the same as assigning the value to
the control

If this is a combo:
If the lot number is not in the list, I assume you have
LimitToList=no

Do you have LimitToList=yes and are trying to add an item to
the list?

If this is a listbox... you have to pick something that is
on the list. And if it is a listbox, it is single-select?

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
I don't think that will work either. This lot number is not in a list the
database does a calculation to generate this number. The lot number is not
part of a list. Our lot numbers are generated through a query function:
Max Of Sample ID: Max([Sample Registration].[Sample ID])+1

is there code that I can put in there that will put the focus in the list
box (called Sample ID) and simulate a mouse click in that box? You know when
you click in a list box it turns black to show it is selected, that is what I
need to happen automatically. I am sorry for the trouble, I am still learning
as I go.

:

Hi Halo,

if what you want it the first item in the list

'list has heading row
me.controlname = [controlname].[ItemData](1)

'list does not have heading row
me.controlname = [controlname].[ItemData](0)

do this on the LOAD event, not the Open event...

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
I can't assign a value to this text box because it changes every time the
form opens. This is a number that increases by 1 each time.

:



Instead of using SendKeys, simply assign the value to the combo

me.combo_controlname = value


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*

Halocarbon wrote:


I have a database that when my users open a form a macro runs to put the
focus in a box called "Lot Number". The form is named "ETFA". Once the focus
is in the box the macro uses the send keys function {down} to select the
number in the box. When the form first opens the focus is set correctly, but
the send keys function does not work. I can close the form and immediatly
reopen it and the send keys function works. What is wrong and can I do this
in another way other than the send keys function?
 
G

Guest

ok....I am sorry for the confusion. You were correct. It is a list box, and
it is sinfle select. The Lot number is the only item in the list box. I tried
your
'list does not have heading row
me.controlname = [controlname].[ItemData](0)
but i get an action failed error every time. Maybe I have entered it wrong
here is what I have.

Click a command button to Open the "ETFA Form" form.
When "ETFA" Form Opens the on load property runs a macro called "ETFA.Lock
Lot Number"
This is the macro:GoToControl: Date
SetValue:
Item: [Forms]![ETFA Form]![date]
Expression: Now()
GoToControl: HalocarbonLotNumber
Run Code: me.halocarbonlotnumber =
[halocarbonlotnumber].[ItemData](0)

Everything works except the run code line. Have I input something wrong? All
of your ideas have been greatly appreciated and I truly thank you for taking
the time to help me out!

strive4peace" <"strive4peace2006 at yaho said:
Hi Halo,

I am a bit confused... clicking on an entry is the same as
selecting it, which is the same as assigning the value to
the control

If this is a combo:
If the lot number is not in the list, I assume you have
LimitToList=no

Do you have LimitToList=yes and are trying to add an item to
the list?

If this is a listbox... you have to pick something that is
on the list. And if it is a listbox, it is single-select?

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
I don't think that will work either. This lot number is not in a list the
database does a calculation to generate this number. The lot number is not
part of a list. Our lot numbers are generated through a query function:
Max Of Sample ID: Max([Sample Registration].[Sample ID])+1

is there code that I can put in there that will put the focus in the list
box (called Sample ID) and simulate a mouse click in that box? You know when
you click in a list box it turns black to show it is selected, that is what I
need to happen automatically. I am sorry for the trouble, I am still learning
as I go.

:

Hi Halo,

if what you want it the first item in the list

'list has heading row
me.controlname = [controlname].[ItemData](1)

'list does not have heading row
me.controlname = [controlname].[ItemData](0)

do this on the LOAD event, not the Open event...

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*

Halocarbon wrote:

I can't assign a value to this text box because it changes every time the
form opens. This is a number that increases by 1 each time.

:



Instead of using SendKeys, simply assign the value to the combo

me.combo_controlname = value


Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*

Halocarbon wrote:


I have a database that when my users open a form a macro runs to put the
focus in a box called "Lot Number". The form is named "ETFA". Once the focus
is in the box the macro uses the send keys function {down} to select the
number in the box. When the form first opens the focus is set correctly, but
the send keys function does not work. I can close the form and immediatly
reopen it and the send keys function works. What is wrong and can I do this
in another way other than the send keys function?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top