Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetFocus problem

Status
Not open for further replies.

frontside

Technical User
Sep 26, 2002
85
SE
I have a form that prints out some labels, after the printout I want the focus to get back to the form (on a specific field, Artikelnr). My code (on the button in the form) is

stDocName = "Etikett kundensartikelnr"
DoCmd.OpenReport stDocName, acViewPreview
DoCmd.PrintOut , , , , i, False 'i = how many labels
DoCmd.Close acReport, stDocName
DoCmd.OpenForm "Etikettkundensartikelnummer"
1.Forms!etikettkundensartikelnummer.Artikelnr.SetFocus
2.Me.Artikelnr.SetFocus


in both tests I get an error message "Cant move the marking to Artikelnr" when I click the OK button it puts focus on the right field.

the code works but I get that annoying messagebox popping up everytime,

do you have any ideas how to get rid of the error message or is my code wrong?


Thankful for any suggestions


micke
 
Hi,

Change this:

Forms!etikettkundensartikelnummer.Artikelnr.SetFocus

To:

Forms!etikettkundensartikelnummer!Artikelnr.SetFocus

If Artikelnr is the name of the field and not the text box, change it to the name of the text box.
 
Thanks!! It gave me some fresh thinking and I found the problem, (There was a macro that did the same thing and as soon I got rid of the macro my/your code worked).

It´s always nice to post here on Tek-tips!!



Thanks again, Nowell


Micke "Sweden"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top