2017-05-08 5 views
1

Ich versuche, eine ActiveX-Befehlsschaltfläche ein Benutzerformular namens "DataEntryUserForm" anzuzeigen.Befehlsschaltfläche zum Anzeigen eines Benutzerformulars

Private Sub CommandButton1_Click() 

DataEntryUserForm.Show 

End Sub 

Oben ist der aktuelle Code für die Befehlsschaltfläche. Wenn ich auf die Schaltfläche klicken erhalte ich folgende Fehlermeldung:

Run-time error '424'
Object required

Ich habe versucht, sich nach einem ähnlichen Problem, konnte aber nichts finden.

Hinzufügen von Benutzerformularcode: (. Doppelklicken Sie in Ihrem Benutzerformular bearbeiten/zu sehen, es ist Codes)

Private Sub DataEntryUserForm_Initialize() 

'Empty PatientIdentifierTextBox 
PatientIdentifierTextBox.Value = "" 

'Empty AgeTextBox 
AgeTextBox.Value = "" 

'Empty SexComboBox 
SexComboBox.Clear 

'Fill SexComboBox 
With SexComboBox 
.AddItem "Male" 
.AddItem "Female" 
End With 

'Unselect AlergiesOptionButtons 
AllergiesYesOptionButton1.Value = False 
AllergiesNoOptionButton2.Value = False 

'Set no car as default 
CarOptionButton2.Value = True 

'Empty PrimaryDiagnosisTextBox 
PrimaryDiagnosisTextBox.Value = "" 

'Empty ReasonforTransfusionTextBox 
ReasonforTransfusionTextBox.Value = "" 

'Empty NumberofTransfusionsTextBox 
NumberofTransfusionsTextBox.Value = "" 

'Empty TypeofTRXNComboBox 
TypeofTRXNComboBox.Clear 

'Fill TypeofTRXNComboBox 
With TypeofTRXNComboBox 
.AddItem "TACO" 
.AddItem "TRALI" 
.AddItem "TAD" 
.AddItem "Allergic Reaction" 
.AddItem "Hypotensive TRXN" 
.AddItem "FNHTR" 
.AddItem "AHTR" 
.AddItem "DHTR" 
.AddItem "DSTR" 
.AddItem "TAGVHD" 
.AddItem "TTI" 
.AddItem "Other" 
End With 

'Empty TreatmentofTRXNTextBox 
TreatmentofTRXNTextBox.Value = "" 

'Empty NumberofTransfusionsBeforeTextBox 
NumberofTransfusionsBeforeTextBox.Value = "" 

'Empty SignsSymptomsTextBox 
SignsSymptomsTextBox.Value = "" 

'Empty ImputabilityComboBox1 
ImputabilityComboBox1.Clear 

'Fill ImputabilityComboBox1 
With ImputabilityComboBox1 
.AddItem "Definite" 
.AddItem "Probable" 
.AddItem "Possible" 
.AddItem "Doubtful" 
.AddItem "Ruled Out" 
.AddItem "Not Determined" 
End With 

'Empty SeverityComboBox2 
SeverityComboBox2.Clear 

'Fill SeverityComboBox2 
With SeverityComboBox2 
.AddItem "Non-Severe" 
.AddItem "Severe" 
.AddItem "Life-threatening" 
.AddItem "Death" 
End With 

'Unselect TreatmentOptionButtons 
TreatmentDrugOptionButton1.Value = False 
TreatmentProductsOptionButton2.Value = False 
TreatmentDrugandProductOptionButton3.Value = False 

'Empty TypeofDrugTextBox 
TypeofDrugTextBox.Value = "" 

'Clear ProductModCheckBox 
VolumeReductionCheckBox1.Value = False 
SalineWashingCheckBox2.Value = False 

'Empty TRXNBeforeChangeTextBox 
TRXNBeforeChangeTextBox.Value = "" 

'Empty TRXNAfterChangeTextBox 
TRXNAfterChangeTextBox.Value = "" 

'Set Focus on NameTextBox 
NameTextBox.SetFocus 

End Sub 
Private Sub OKButton_Click() 

Dim emptyRow As Long 

'Make Sheet1 active 
Sheet1.Activate 

'Determine emptyRow 
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1 

'Transfer information 
Cells(emptyRow, 1).Value = PatientIdentifierTextBox.Value 
Cells(emptyRow, 2).Value = AgeTextBox.Value 
Cells(emptyRow, 3).Value = SexComboBox.Value 
Cells(emptyRow, 5).Value = PrimaryDiagnosisTextBox.Value 
Cells(emptyRow, 6).Value = ReasonforTransfusionTextBox.Value 
Cells(emptyRow, 7).Value = NumberofTransfusionsTextBox.Value 
Cells(emptyRow, 8).Value = TypeofTRXNComboBox.Value 
Cells(emptyRow, 9).Value = TreatmentofTRXNTextBox.Value 
Cells(emptyRow, 10).Value = NumberofTransfusionsBeforeTextBox.Value 
Cells(emptyRow, 11).Value = SignsSymptomsTextBox.Value 
Cells(emptyRow, 12).Value = ImputabilityComboBox1.Value 
Cells(emptyRow, 13).Value = SeverityComboBox2.Value 
Cells(emptyRow, 15).Value = TypeofDrugTextBox.Value 
Cells(emptyRow, 17).Value = TRXNBeforeChangeTextBox.Value 
Cells(emptyRow, 18).Value = TRXNAfterChangeTextBox.Value 


If AllergiesYesOptionButton1.Value = True Then Cells(emptyRow, 4).Value = 
AllergiesYesOptionButton1.Caption 

If AllergiesNoOptionButton2.Value = True Then Cells(emptyRow, 4).Value = 
Cells(emptyRow, 4).Value & " " & AllergiesNoOptionButton2.Caption 

End If 

If TreatmentDrugOptionButton1.Value = True Then Cells(emptyRow, 14).Value = 
TreatmentDrugOptionButton1.Caption 

If TreatmentProductsOptionButton2.Value = True Then Cells(emptyRow, 
14).Value = Cells(emptyRow, 14).Value & " " & 
TreatmentProductsOptionButton2.Caption 

If TreatmentDrugandProductOptionButton3.Value = True Then Cells(emptyRow, 14).Value = Cells(emptyRow, 14).Value & " " & 
TreatmentDrugandProductOptionButton3.Caption 

End If 

If VolumeReductionCheckBox1.Value = True Then Cells(emptyRow, 16).Value = VolumeReductionCheckBox1.Caption 

If SalineWashingCheckBox2.Value = True Then Cells(emptyRow, 16).Value = Cells(emptyRow, 16).Value & " " & SalineWashingCheckBox2.Caption 

End If 

End Sub 
Private Sub ClearButton_Click() 

Call UserForm_Initialize 

End Sub 
Private Sub CancelButton_Click() 

Unload Me 

End Sub 

Antwort

1

Versuchen Sie Private Sub UserForm_Initialize() Code

Private Sub DataEntryUserForm_Initialize()

Ändern

(Und ich bin mir nicht sicher, ob Sie Ihr Benutzerformular hinzugefügt haben oder nicht. Wenn Sie nicht versuchen, UserForm hinzuzufügen - In der Visua l Basic Editor klicken Sie auf die Schaltfläche UserForm einfügen - oder gehen Sie auf Einfügen> UserForm)

+0

Hinzugefügt Benutzer Formular Codierung – pmgibs

+0

Also, was ist das Ergebnis? Wenn es immer noch nicht funktioniert, versuchen Sie, Ihr Visual Basic-Fenster zu öffnen, und drücken Sie F8 nacheinander, und sagen Sie mir, welche Zeile einen Fehler ergibt/hervorgehoben wird. – Mertinc

Verwandte Themen