Checkbox en bladwijzers

Status
Niet open voor verdere reacties.

dopekoe

Gebruiker
Lid geworden
8 feb 2002
Berichten
37
Goedemiddag,

Ik ben een userform aan het maken wat opzich wel goed gaat afgezien van 2 problemen:

Ik wil graag een radiobutton gebruik voor het automatisch laten invullen van 3 waardes bij 3 bladwijzers. De waardes die ingevuld moeten worden wil ik hard in de code hebben staan.

Het plaatsen van de waardes is het probleem niet, als ik namelijk een radiobutton activeer dan wordt de text netjes op het juiste veld geplaatst, maar wanneer ik daarna een andere radiobutton selecteer (van hetzelfde frame) dan worden de waardes niet overschreven maar er achter geplakt.

Ik heb niet kunnen vinden waar ik er voor kan zorgen dat de waardes overschreven worden ipv erachter geplaatst worden.

De code ziet er als volgt uit:

Code:
Private Sub invoegen_Click()
    Medewerker.Hide
        Selection.GoTo what:=wdGoToBookmark, Name:="medewerker"
            Selection.TypeText naam.Text
        Selection.GoTo what:=wdGoToBookmark, Name:="medewerker2"
            Selection.TypeText naam.Text
        Selection.GoTo what:=wdGoToBookmark, Name:="onderwerp"
            Selection.TypeText onderwerp.Text
End Sub

Private Sub sonde_click()
    If sonde.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="telefoon"
            Selection.TypeText Text:="030-8888888"
    If sonde.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="fax"
            Selection.TypeText Text:="030-7777777"
    If sonde.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="email"
            Selection.TypeText Text:="mail4@mail.com"
End Sub
Private Sub stof_click()
    If stof.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="telefoon"
            Selection.TypeText Text:="030-6666666"
    If stof.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="fax"
            Selection.TypeText Text:="030-5555555"
    If stof.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="email"
            Selection.TypeText Text:="mail3@mail.com"
End Sub

Private Sub drink_click()
    If drink.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="telefoon"
            Selection.TypeText Text:="030-4444444"
    If drink.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="fax"
            Selection.TypeText Text:="030-3333333"
    If drink.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="email"
            Selection.TypeText Text:="mail2@mail.com"
End Sub

Private Sub kinder_click()
    If kinder.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="telefoon"
            Selection.TypeText Text:="030-1111111"
    If kinder.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="fax"
            Selection.TypeText Text:="030-2222222"
    If kinder.Value Then Selection.GoTo what:=wdGoToBookmark, Name:="email"
            Selection.TypeText Text:="mail@mail.coml"
End Sub

Ik weet dat _click() ervoor zorgt dat de waardes er al direct komen te staan en ik weet ook dat de 'IF-jes' er niet mooi uitzien maar functioneel is belangrijker dan looks ;)

Iemand een oplossing?
 
Veld eerst leeg maken en vervolgens vullen met tekst misschien? Dus:

If voorwaarde = X then
veldnaam.text = ""
veldnaam.text = "Tekst"
End IF

Charles
 
Code:
Private Sub invoegen_Click()
  Medewerker.Hide
  With Activedocument
    .Bookmarks("medewerker")=naam.Text
    .Bookmarks("medewerker2")=naam.text
    .Bookmarks("onderwerp")=onderwerp.Text 
  End With 
End Sub

Code:
Private Sub sonde_click()
  If sonde.Value Then 
     With Activedocument
       .Bookmarks("telefoon")=")="030-7777777"
       .Bookmarks("fax")="030-7777777"
       .Bookmarks("email")="mail4@mail.com" 
     End With
  End If
End Sub

Code:
Private Sub stof_click()
    If stof.Value Then 
    With Activedocument
       .Bookmarks("telefoon")=")="030-6666666"
       .Bookmarks("fax")="030-5555555"
       .Bookmarks("email")="mail3@mail.com" 
     End With
  End If
End Sub

Code:
Private Sub drink_click()
  If drink.Value Then 
    With Activedocument
       .Bookmarks("telefoon")=")="030-4444444"
       .Bookmarks("fax")="030-3333333"
       .Bookmarks("email")="mail5@mail.com" 
     End With
  End If
End Sub
Code:
Private Sub kinder_click()
  If kinder.Value Then
    With Activedocument
       .Bookmarks("telefoon")=")="030-1111111"
       .Bookmarks("fax")="030-2222222"
       .Bookmarks("email")="mail@mail.com" 
     End With
  End If
End Sub

Als je in plaats van bladwijzers documentvariabelen (menubalk/invoegen/veld/docvariable) gebruikt is alles simpeler:

Code:
Private Sub invoegen_Click()
  Medewerker.Hide
  With Activedocument
    .Variables("medewerker")=naam.Text
    .Variabels("medewerker2")=naam.text
    .Variable("onderwerp")=onderwerp.Text 
    .Fields.update
  End With 
End Sub

En de overige code is analoog.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan