发现标签会起作用。我使用我的“form1”并在设计视图中打开“form2”并隐藏并放置 vba 代码来编辑标签的标题,然后保存“form2”。我关闭并打开“form2”,标题按我想要的方式保存。我可以摆脱我的全局变量,因为我不再需要它们。下面是“form1”的样子:
Private Sub Push_Click()
'Variable for date if PM was completed outside of required completion month
Dim newdate As Date
Dim newTech As String
'When Push is clicked, adds all values to the Log Table
CurrentDb.Execute "INSERT INTO Log([GE Printer], [Date Completed], [Report Type], [Pre 12mW], [Pre 25mW], [Pre 38mW], [Pre 50mW], [Pre 75mW], [Pre 100mW], [Pre 150mW], [Pre 200mW], [Post 12mW], [Post 25mW], [Post 38mW], [Post 50mW], [Post 75mW], [Post 100mW], [Post 150mW], [Post 200mW], [X Notch Freq], [X Gain], [X FF], [X VFF], [Y Notch Freq], [Y Gain], [Y FF], [Y VFF], [Encoder Cal], [Laser SN], [Laser Head SN], [Install HRS], [Current HRS], [Warranty HRS], [Blade Gap], [Blade Gap Offset], Threshold, [Laser RFID], [Cart RFID], [VAT RFID], [Old X Beamsize], [New X Beamsize], [Old Y Beamsize], [New Y Beamsize], ADC, Notes, [Laser Focus], Technician, [Total Laser HRS], [Printer SN]) " & _
" VALUES(" & Me.GE_ & ",'" & Me.txtDate & "','" & Me.txtReport & "','" & Me.Pre12 & "','" & Me.Pre25 & "','" & Me.Pre38 & "','" & Me.Pre50 & "','" & Me.Pre75 & "','" & Me.Pre100 & "','" & _
Me.Pre150 & "','" & Me.Pre200 & "','" & Me.Post12 & "','" & Me.Post25 & "','" & Me.Post38 & "','" & Me.Post50 & "','" & Me.Post75 & "','" & Me.Post100 & "','" & Me.Post150 & "','" & _
Me.Post200 & "','" & Me.XNotch & "','" & Me.XGain & "','" & Me.XFF & "','" & Me.XVFF & "','" & Me.YNotch & "','" & Me.YGain & "','" & Me.YFF & "','" & Me.YVFF & "','" & Me.Encoder & "','" & _
Me.SN & "','" & Me.HeadSN & "','" & Me.Install & "','" & Me.Current & "','" & Me.Warranty & "','" & Me.PhyGap & "','" & Me.Offset & "','" & Me.Threshold & "','" & Me.Laser & "','" & _
Me.Cart & "','" & Me.Vat & "','" & Me.BeforeX & "','" & Me.AfterX & "','" & Me.BeforeY & "','" & Me.AfterY & "','" & Me.ADC & "','" & Me.Notes & "','" & Me.Focus & "','" & Me.Tech & "','" & _
Me.Total & "','" & Me.Asset_ & "')"
newTech = CStr(Me.Tech)
DoCmd.OpenForm "PMsch", acDesign, , , , acHidden
'Applies info to the PMSch form
'301
If Me.GE_ = "301" Then
If DatePart("m", Me.txtDate) = 1 Then
Forms("PMsch")("lbl301Jan").Caption = Me.txtDate
Forms("PMsch")("lbl301TechJan").Caption = newTech
ElseIf DatePart("m", Me.txtDate) = 4 Then
Forms("PMsch")("lbl301Apr").Caption = Me.txtDate
Forms("PMsch")("lbl301TechApr").Caption = newTech
ElseIf DatePart("m", Me.txtDate) = 7 Then
Forms("PMsch")("lbl301Jul").Caption = Me.txtDate
Forms("PMsch")("lbl301TechJul").Caption = newTech
ElseIf DatePart("m", Me.txtDate) = 10 Then
Forms("PMsch")("lbl301Oct").Caption = Me.txtDate
Forms("PMsch")("lbl301TechOct").Caption = newTech
Else
newdate = InputBox("Please input Date as m/d/yyyy.")
If DatePart("m", newdate) = 12 Or 2 Then
Forms("PMsch")("lbl301Jan").Caption = newdate
Forms("PMsch")("lbl301TechJan").Caption = newTech
ElseIf DatePart("m", newdate) = 3 Or 5 Then
Forms("PMsch")("lbl301Apr").Caption = newdate
Forms("PMsch")("lbl301TechApr").Caption = newTech
ElseIf DatePart("m", newdate) = 6 Or 8 Then
Forms("PMsch")("lbl301Jul").Caption = newdate
Forms("PMsch")("lbl301TechJul").Caption = newTech
ElseIf DatePart("m", newdate) = 9 Or 11 Then
Forms("PMsch")("lbl301Oct").Caption = newdate
Forms("PMsch")("lbl301TechOct").Caption = newTech
End If
End If
End If
现在我只需要完成其他所有代码的编码并准备好与其他技术人员一起测试它。关闭/保存的 docmd 位于最后一台打印机的最底部,因此它没有显示在我的代码中。