I loose Focus when I paste

G

Guest

This is a very old DB and who ever did this did not documented anything, I'm
lost and I need help. There is this bottom that copy a full record and paste
it at the very end (RecordsGoToNew) then trys to (Sendkeys KeyStroke
(.1{Enter})) but some times it writes it at the record field and sometime it
writes it at the end of the record, so the macro sends me a message that I'm
creating duplicate records. How can I force the focus on to the Record#?
Thank you for the help!
 
S

Steve Schapel

Pechetico,

I would advise against trying to manage data in a database using
copy/paste, and also advise against using the SendKeys action.

A much better way here is to use an OpenQuery action in your macro to
run an Append Query based on the current record. I suggest you replace
the part of trhe macro you have mentioned with the append query approach.
 
G

Guest

I apreciate the help. But I want you to know that I'm not very knowedgeable
on the VB part. This is what I got on the Macro that I have


Copy_quote Echo
runcommand:SaveRecord
runcommand:Refresh
opentable: Quote; Datasheet; Edit
FindRecord: =[forms]!
![record#]
runcommand:selectrecord
runcommand: copy
runcommand:recordsgotonew
runcommand:slectrecord
runcommand:paste
sendkeys: .1{enter}; yes
setwarnings: no
close: table; quote
setwarning:yes
gotocontrol:[record#]
runcommand:removedfiltersort
findrecord:.1
setvalue: [forms]!
![record#] ;
[forms]!
![embedded178].[form]![record#]+1
runcommand: removefiltersort
findrecord

when ever it goes to the runcommand: paste, sometimes it goes to the first
space on the record and the rest of the macro works fine but sometimes it
goes to the end of the record and that is where it writes the .1 . Some
computers works fine (this ones does not have int explorer 7.0) but the rest
of them sometimes it works and sometimes does not (all this ones have the
internet explorer 7.0 that later was removed, but still does not work). All
this works on a pear to pear net. I do not know much about the programming
part, I know that the aplication works on some computer so I think has
something to do with communication problems. Can you help me please. Thank
you for your help
 
S

Steve Schapel

Pechetico,

Thanks for the further explanation.

I can tell you that this is a very un-satisfactory approach. For a
number of reasons, really. We are dealing with a database, and as such
copy/paste is never a good idea. Second, the use of SendKeys in this
context is unreliable. Third, manipulating data directly in tables is
never a good idea. Fourth, there is almost certainly a lot easier way.

So, can you tell me, just in ordinary description, what the purpose of
this procedure is? I got the idea that you are makign a new record, and
copying the value from one of the fields into this new record. Is that
right? Or is it the whole record? But I can't quite understand about
the .1 or the role of the [record#]. And how do you know which record
to duplicate?

--
Steve Schapel, Microsoft Access MVP
I apreciate the help. But I want you to know that I'm not very knowedgeable
on the VB part. This is what I got on the Macro that I have


Copy_quote Echo
runcommand:SaveRecord
runcommand:Refresh
opentable: Quote; Datasheet; Edit
FindRecord: =[forms]!
![record#]
runcommand:selectrecord
runcommand: copy
runcommand:recordsgotonew
runcommand:slectrecord
runcommand:paste
sendkeys: .1{enter}; yes
setwarnings: no
close: table; quote
setwarning:yes
gotocontrol:[record#]
runcommand:removedfiltersort
findrecord:.1
setvalue: [forms]!
![record#] ;
[forms]!
![embedded178].[form]![record#]+1
runcommand: removefiltersort
findrecord

when ever it goes to the runcommand: paste, sometimes it goes to the first
space on the record and the rest of the macro works fine but sometimes it
goes to the end of the record and that is where it writes the .1 . Some
computers works fine (this ones does not have int explorer 7.0) but the rest
of them sometimes it works and sometimes does not (all this ones have the
internet explorer 7.0 that later was removed, but still does not work). All
this works on a pear to pear net. I do not know much about the programming
part, I know that the aplication works on some computer so I think has
something to do with communication problems. Can you help me please. Thank
you for your help
 
G

Guest

First I want to thank you for your help. I really apreciate it.
This is an aplication that we use to quote our product. On the quote window
we have several buttons and this particular one is a "Copy Quote". What I
could understand from this, is that the present quote (record#) is copied in
its full length (104 colums) to the bottom of the table then the key value is
change to .1 .Who ever did this application assumed that after pasting the
cursos was going to be place at the begining on the record but in this case
it does not. After that, it goes and finds the last record and store that
number on a variable ([Embedded178]) and then goes and looks for the record
..1 in the table and change the value of the key (record#) to the saved
variable ([Embedded178]+1). Once all this is done the user can change some
fields if necesary. We do alot of repetitive quotes with very minor changes.
I understand that this is a non safe or the right way of programming but it
has being working for the past 10 years -it still works on some computer-
I do not desire to reprogram this application because we are in the proscess
of creating a new program (full VB program) and not an MS Access aplication.
This, what I understand would take several monts but in the mean time we need
this old application so we can sell our product. So what I'm trying to do is
to find out why it mess up when we installed IE 7.0 and how can I fixed it in
the mean time.
One again thank you for your help.

Steve Schapel said:
Pechetico,

Thanks for the further explanation.

I can tell you that this is a very un-satisfactory approach. For a
number of reasons, really. We are dealing with a database, and as such
copy/paste is never a good idea. Second, the use of SendKeys in this
context is unreliable. Third, manipulating data directly in tables is
never a good idea. Fourth, there is almost certainly a lot easier way.

So, can you tell me, just in ordinary description, what the purpose of
this procedure is? I got the idea that you are makign a new record, and
copying the value from one of the fields into this new record. Is that
right? Or is it the whole record? But I can't quite understand about
the .1 or the role of the [record#]. And how do you know which record
to duplicate?

--
Steve Schapel, Microsoft Access MVP
I apreciate the help. But I want you to know that I'm not very knowedgeable
on the VB part. This is what I got on the Macro that I have


Copy_quote Echo
runcommand:SaveRecord
runcommand:Refresh
opentable: Quote; Datasheet; Edit
FindRecord: =[forms]!
![record#]
runcommand:selectrecord
runcommand: copy
runcommand:recordsgotonew
runcommand:slectrecord
runcommand:paste
sendkeys: .1{enter}; yes
setwarnings: no
close: table; quote
setwarning:yes
gotocontrol:[record#]
runcommand:removedfiltersort
findrecord:.1
setvalue: [forms]!
![record#] ;
[forms]!
![embedded178].[form]![record#]+1
runcommand: removefiltersort
findrecord

when ever it goes to the runcommand: paste, sometimes it goes to the first
space on the record and the rest of the macro works fine but sometimes it
goes to the end of the record and that is where it writes the .1 . Some
computers works fine (this ones does not have int explorer 7.0) but the rest
of them sometimes it works and sometimes does not (all this ones have the
internet explorer 7.0 that later was removed, but still does not work). All
this works on a pear to pear net. I do not know much about the programming
part, I know that the aplication works on some computer so I think has
something to do with communication problems. Can you help me please. Thank
you for your help
 
G

Guest

First I want to thank you for your help. I really apreciate it.
This is an aplication that we use to quote our product. On the quote window
we have several buttons and this particular one is a "Copy Quote". What I
could understand from this, is that the present quote (record#) is copied in
its full length (104 colums) to the bottom of the table then the key value is
change to .1 .Who ever did this application assumed that after pasting the
cursos was going to be place at the begining on the record but in this case
it does not. After that, it goes and finds the last record and store that
number on a variable ([Embedded178]) and then goes and looks for the record
..1 in the table and change the value of the key (record#) to the saved
variable ([Embedded178]+1). Once all this is done the user can change some
fields if necesary. We do alot of repetitive quotes with very minor changes.
I understand that this is a non safe or the right way of programming but it
has being working for the past 10 years -it still works on some computer-
I do not desire to reprogram this application because we are in the proscess
of creating a new program (full VB program) and not an MS Access aplication.
This, what I understand would take several monts but in the mean time we need
this old application so we can sell our product. So what I'm trying to do is
to find out why it mess up when we installed IE 7.0 and how can I fixed it in
the mean time.
One again thank you for your help.

Steve Schapel said:
Pechetico,

Thanks for the further explanation.

I can tell you that this is a very un-satisfactory approach. For a
number of reasons, really. We are dealing with a database, and as such
copy/paste is never a good idea. Second, the use of SendKeys in this
context is unreliable. Third, manipulating data directly in tables is
never a good idea. Fourth, there is almost certainly a lot easier way.

So, can you tell me, just in ordinary description, what the purpose of
this procedure is? I got the idea that you are makign a new record, and
copying the value from one of the fields into this new record. Is that
right? Or is it the whole record? But I can't quite understand about
the .1 or the role of the [record#]. And how do you know which record
to duplicate?

--
Steve Schapel, Microsoft Access MVP
I apreciate the help. But I want you to know that I'm not very knowedgeable
on the VB part. This is what I got on the Macro that I have


Copy_quote Echo
runcommand:SaveRecord
runcommand:Refresh
opentable: Quote; Datasheet; Edit
FindRecord: =[forms]!
![record#]
runcommand:selectrecord
runcommand: copy
runcommand:recordsgotonew
runcommand:slectrecord
runcommand:paste
sendkeys: .1{enter}; yes
setwarnings: no
close: table; quote
setwarning:yes
gotocontrol:[record#]
runcommand:removedfiltersort
findrecord:.1
setvalue: [forms]!
![record#] ;
[forms]!
![embedded178].[form]![record#]+1
runcommand: removefiltersort
findrecord

when ever it goes to the runcommand: paste, sometimes it goes to the first
space on the record and the rest of the macro works fine but sometimes it
goes to the end of the record and that is where it writes the .1 . Some
computers works fine (this ones does not have int explorer 7.0) but the rest
of them sometimes it works and sometimes does not (all this ones have the
internet explorer 7.0 that later was removed, but still does not work). All
this works on a pear to pear net. I do not know much about the programming
part, I know that the aplication works on some computer so I think has
something to do with communication problems. Can you help me please. Thank
you for your help
 

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