Avatar billede christian_h Nybegynder
02. april 2004 - 23:56 Der er 31 kommentarer og
1 løsning

Markere tekst i 4 textboxe ved tryk på en knap + mere

Hej Alle.

Jeg har en Access form, hvorpå der er 4 textbox'e. Det jeg gerne vil er at når man trykker på en kommandoknap, så bliver teksten i disse 4 textbox'e ALLE makeret på en gang, og herefter skal der simuleres at man trykker på <ctrl> + højre musseklik.

Er der nogen der kan hjælpe med der ???.

HJÆÆÆLLLPPP.

Mvh.

Christian_h
Avatar billede geisiqve Nybegynder
03. april 2004 - 09:10 #1
Hva ønsker du egentlig å oppnå

Mvh

Geir
Avatar billede christian_h Nybegynder
03. april 2004 - 09:18 #2
Hej Geir.

Det er fordi jeg har en label printer, hvor man kan gøre følgende:

Lad os sige at man har skrevet en adresse i et word doc, og man herefter markere teksten med musen så den bliver sort, hvis man herefter holder musen hend over den markerede tekst, og trykker <ctrl> + højre musseknap ned, bliver teksten automatisk ført ind i label printer programmet, hvor man så bare kan trykke print. dette vil jg gerne have til at virke i min Database, så når jeg på en form har vist en adresse fra databasen i de 4 textbox'e, og trykker på en kommandoknap, så bliver de 4 texbox'ene makeret og der bliver simuleret <ctrl> + højre musseklik.

Håber at dette giver lidt mere forståelse.

Mvh.

Christian_h
Avatar billede mugs Novice
03. april 2004 - 19:43 #3
Hvorfor benytter du ikke Access' Guide til etiketudskrivning?
Hvis du kun vil udskrive een enkelt adresse, kan du gøre det fra en formular. Hvis du vil udskrive alle eller en begrænset del af dine adresser kan du også gøre dette. Udelukkende et spørgsmål om kriterier.
Avatar billede christian_h Nybegynder
03. april 2004 - 20:10 #4
Hvordan finder man den guide ??
Avatar billede mugs Novice
03. april 2004 - 20:12 #5
Åbn db i databasevinduet > Fanen Rapporter > Ny > Guiden Etiket
Avatar billede fynbohans Nybegynder
03. april 2004 - 20:51 #6
Når det er en Label-printer du bruger
skal du bare lave en almindlig rapport med dine 4 felt og
en knap i formularen til udskrift.
Avatar billede christian_h Nybegynder
03. april 2004 - 22:22 #7
Det skal IKKE være en rapport, det skal være på den samme form som man indtaster daterne i, derfor har jeg valgt at det skal gøres på den måde som er beskrevet ovenfor, er der nogen der kan hjælpe med det ??

Christian_h
Avatar billede terry Ekspert
04. april 2004 - 10:12 #8
Christian and I correct in saying  that this feater "<ctrl> + højre musseklik" is available only because there is some software installed on your PC? It isnt a standard feature in windows is it? and if it isnt then I dont think it is anything you can make use of in Access.
In Access you cant select text in four differenet fields at once, unless they are in the same record, but it is the record which is selected and NOT the text!

So a quick answer to your quetsion is it isnt possible!
Avatar billede christian_h Nybegynder
04. april 2004 - 11:30 #9
Hi Terry.

YES you are right about the "<ctrl> + højre musseklik" that is a feature of the labeprinter SW, so if you are in let's say word, and you select some text, and the do the "<ctrl> + højre musseklik" it will automaticlly open up the labeprinter SW and put in th selected text in the right way.

Isn't there a whay to show 4 different records in textbox or listbox or what ever like this, and then select it.

Sir mane Last name
Adress
zip code City

Best regards from.

Christian_h
Avatar billede terry Ekspert
04. april 2004 - 11:41 #10
IK, I dont know ANYTHING about how your printer works, but if you "<ctrl> + højre musseklik" in one field in Access does it work? If it does work then you could make a seperate field containing the text from other other foure fields and then use this field for printing your lable.
Avatar billede terry Ekspert
04. april 2004 - 11:47 #11
I dont know how you are getting the data into the four fields but lets say you have an extra field. When you press on the button you could copy the values from these foure fields into the new field with some code similar to this. The code is in the buttons On Click event.

Me.YourNew Field = Me.fld1 & vbCrlf & Me.fld2 & vbCrLf & Me.fld3 & vbCrLf & VbCrLf & "Best regardds from." & vbCrLf & vbCrLf & me.fld3
Avatar billede christian_h Nybegynder
04. april 2004 - 11:49 #12
It does work in access when i select a field and then do the "<ctrl> + højre musseklik" it then opens up the label SW and then insert the selected text.

How do I make what you are saying ??.

Best regards.

Christian_h
Avatar billede terry Ekspert
04. april 2004 - 11:55 #13
Do you have a form which uses data from a table, or do you enter the data directly into the four fields?

In BOTH cases you need an extra field (unbound) and a button on the form. Do you have any programming experience? If not then now is the time to learn :o)

I can have a look at the dB if you send it to NOSPAMeksperten@santhell.dkNOSPAM

remove NOSPAM
Avatar billede christian_h Nybegynder
04. april 2004 - 12:06 #14
Hi Terry.

Now I got that part working, the records is now ALL in the new textbox in the right way.

Now how can I make so all that text in that new textbox is selected, and simulate the "<ctrl> + højre musseklik" over that new textbox ?
Avatar billede terry Ekspert
04. april 2004 - 12:34 #15
I'm not quite sure how to simulate a right mouse button click, I'll look into that and get back as soon as possible but place this code in the buttons on click event. It selects all of teh text.


Me.YourField.SetFocus
Me.YourField.SelStart = 0
Me.YourField.SelLength = Len(Me.YourField)

and change YourField to the correct name
Avatar billede terry Ekspert
04. april 2004 - 14:50 #16
OK, here is a solution which I obvioulsy cant test as I dont have your printer and software.

Make a new module with this code

Option Compare Database
Option Explicit

Private Const MOUSEEVENTF_ABSOLUTE = &H8000
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
Private Const MOUSEEVENTF_MIDDLEUP = &H40
Private Const MOUSEEVENTF_MOVE = &H1
Private Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10

Public Enum enButtonToClick
    btcLeft
    btcRight
    btcMiddle
End Enum

Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, _
    ByVal dx As Long, ByVal dy As Long, ByVal cbuttons As Long, _
    ByVal dwExtraInfo As Long)

Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Public Const KEYEVENTF_EXTENDEDKEY = &H1
Public Const KEYEVENTF_KEYUP = &H2

Public Function Ctrl_Down()
    keybd_event vbKeyControl, 0, 0, 0
End Function

Public Function Ctrl_Up()
    keybd_event vbKeyControl, 0, KEYEVENTF_KEYUP, 0
End Function

Public Function MouseFullClick(ByVal MBClick As enButtonToClick) As Boolean
    Dim cbuttons As Long
    Dim dwExtraInfo As Long
    Dim mevent As Long
   
    Select Case MBClick
        Case btcLeft
            mevent = MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP
        Case btcRight
            mevent = MOUSEEVENTF_RIGHTDOWN Or MOUSEEVENTF_RIGHTUP
        Case btcMiddle
            mevent = MOUSEEVENTF_MIDDLEDOWN Or MOUSEEVENTF_MIDDLEUP
        Case Else
            MouseFullClick = False
            Exit Function
    End Select
    mouse_event mevent, 0&, 0&, cbuttons, dwExtraInfo
    MouseFullClick = True
   
End Function


Now in the buttons On Click event add this code AFTER where you select the text

Ctrl_Down
MouseFullClick btcRight
Ctrl_Up


I hope it works :o)
Avatar billede christian_h Nybegynder
04. april 2004 - 14:58 #17
Hi Terry.

It allmost works, the only thing that is missing now is that I need to simulate that the right mouse click is done over the new textbox, can this also be solved the 100 point is yours ;-)
Avatar billede terry Ekspert
04. april 2004 - 15:10 #18
This is the bit I cant test as I dont have your printer or software?

The code I have given 04/04-2004 14:50:01 is used to simulate the Ctrl down (Ctrl_Down)
Then right click (MouseFullClick btcRight)
and then finally Ctrl up Ctrl_Up

But I have NO WAY to test that this works as you want it to.
I can see that the code DOES work, but only with the program I have.

Whats happens when you run the code?
Avatar billede terry Ekspert
04. april 2004 - 15:18 #19
christian>I understand danish 100% :o)
Avatar billede christian_h Nybegynder
04. april 2004 - 15:25 #20
Er mit engelsk så dårligt da ??

Jeg kan også se at koden virker, men jeg kan også se at "højre musseklik" bliver udført over kommandoknappen, og IKKE over den "nye" textbox som vi har lavet.
Det vil jeg gerne have ændret således at man får simuleret "højre musseklik" over den nye textbox, hvis dette kan ændres virker det 100%
Avatar billede terry Ekspert
04. april 2004 - 15:37 #21
Nej Nej Christian, dit engelsk er rigtig godt, men det er måske nemmer ikke? :o)

Mmm! I must admit I'm not at all sure how to go about this last bit! Why do things always end up more complicated that first anticipated?

I only thought that it was necessary to select the text and then Ctrl+Right mouse click. But now the mouse has to be over it!

Everything is possible and I am sure this is too but there is quite a bit of work involved and I am pushed for time.
The problem is finding out where the text boxes is and also where the actual text is. Then moving the mouse over it, all in code! Not easy but as I said it is possible.
Avatar billede terry Ekspert
04. april 2004 - 15:38 #22
I know this may sound silly, but is it a big problem just doing it with the mouse?
Avatar billede christian_h Nybegynder
04. april 2004 - 15:58 #23
terry
04/04-2004 15:38:10 I know this may sound silly, but is it a big problem just doing it with the mouse?

Nej egentligt ikke, men det ville være fedt hvis det kunne laves automatisk, så man ikke skulle gøre andet end at trykke på kommandoknappen.

Kan man ikke tilrette det sådan at syntax bliver noget i retning af
Ctrl_Down
MouseFullClick btcRight.textboxXX
Ctrl_Up

"Den" ved jo at textboxen er der !?!?!, så må man også kunne lave det på en "nem" måde ligesom med at markere teksten med "Setfocus" ?!?!?!

Jeg må prøve at løse det, men du skal have nogle point for det du har lavet som virker KANON.
Avatar billede terry Ekspert
04. april 2004 - 16:07 #24
As I said Christain, I am sure it is possible but I just dont have a solution which I can give without quite a bit of work. The problem as I see it is moveing the position of the mouse FROM over the button TO over the selected text. This means finding out where the text box is and then moving the mouse cursor to that position. It may in fact be quite simple, but it isnt someting I do every day, so I would need to play around until I found a solution, and I know that I can end up using hours!
Avatar billede christian_h Nybegynder
04. april 2004 - 16:12 #25
Terry, I eould like to thank you for the help, what you have done is WORKING 100%, so I will give you the 100 point.

Have a nice Sunday.

Best regards from.

Christian_h
Avatar billede terry Ekspert
04. april 2004 - 16:16 #26
When I say "Finding out where the txt box is" It isnt just a case of saying that the window is at a given position. This position can change! The window in which the text box is placed can be moved or resized for example. So it has to be done every time the code is executed.
Avatar billede terry Ekspert
04. april 2004 - 16:17 #27
Thanks Christian, if I do get time I will see if I can find a solution to the final part!
Avatar billede christian_h Nybegynder
04. april 2004 - 16:22 #28
Thanks Terry, I'm also looking into the final part, and I will post it here if I solve it.
Avatar billede terry Ekspert
05. april 2004 - 21:11 #29
Christian>Here is a handy link where you may be able to find information which may be helpfull.
Avatar billede christian_h Nybegynder
05. april 2004 - 23:12 #30
Hi Terry.

Did you forget to put in the link ??.

I have "solved" the problem, in a VERY PURE WAY, but it works, and the DB is only for my own use, so it is OK for now.
What I have done is, that I know that the DB form always opens up in the same place of the screen, so I have just found the X, Y cordinates for that position, at then used the Setcursorpos API to move the cursor to that place and then preform the "højre musseklik". But it also means that I can't hide the "new" textbox, if I do, "your code" can't select it (yet another thing to solve).

I would still like to know the right way to do it, but maybe I can find out if you post the link here.

Best regards from.

Christian_h
Avatar billede terry Ekspert
07. april 2004 - 13:22 #31
Avatar billede terry Ekspert
07. april 2004 - 13:23 #32
Yes it is a bit of a teaser.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester