I ceated a automatic split form from a table called "Master NSN List." I then added 2 buttons "cmdShowHid e" which toggles between showing and hiding the form section giving more room for the datasheet and "cmdFixNSN" which takes a portion of the NSN and puts it in another field then removes all of the dashes.
The form loads fine until i add code to either of the buttons or the form_load event then i get the message "Member already exists in an object module from which this object module derives"
I have tried to change the name of the form and the buttons, deleting the form and recreating it, building a query and basing the form off of it but nothing works.
The form loads fine until i add code to either of the buttons or the form_load event then i get the message "Member already exists in an object module from which this object module derives"
I have tried to change the name of the form and the buttons, deleting the form and recreating it, building a query and basing the form off of it but nothing works.
Code:
Option Compare Database
Option Explicit
Const ShowSplit1 As Single = 5685, HideSplit1 As Single = 1500
Const ShowTop1 As Single = 4320, HideTop1 As Single = 0
Const FSCM As Integer = 4
Dim NoFscm(1 To 2) As Integer, DashFscm(1 To 3) As Integer
Dim intNSN As Integer, intCount As Integer
Dim strNSN(1 To 2) As String, strFSCM As String
Private Function ShowHide(Show As Boolean) As Boolean
With [Form_Master NSN List]
.txtNSN.Visible = Show
.txtFSCM.Visible = Show
.txtEndItem.Visible = Show
.txtRemarks.Visible = Show
.txtCost.Visible = Show
.chkOnOrder.Visible = Show
End With
If Show = True Then
With [Form_Master NSN List]
.SplitFormSize = ShowSplit1
.cmdShowHide.Top = ShowTop1
.cmdShowHide.Caption = "Hide Details"
End With
Else
With [Form_Master NSN List]
.SplitFormSize = HideSplit1
.cmdShowHide.Top = HideTop1
.cmdShowHide.Caption = "Show Details"
End With
End If
ShowHide = Not Show
End Function
Private Sub cmdFixNSN_Click()
'intNSN = Len(txtNSN.Value)
NoFscm(1) = 4
NoFscm(2) = 8
DashFscm(1) = 6
DashFscm(2) = 9
DashFscm(3) = 13
strNSN(1) = txtNSN.Value
intCount = [Form_Master NSN List].Count
Select Case Len(strNSN(1))
Case 16
strFSCM = Left(strNSN(1), FSCM)
txtFSCM.Value = strFSCM
strNSN(2) = Mid(strNSN(1), DashFscm(1), 2)
strNSN(2) = strNSN(2) & Mid(strNSN(1), DashFscm(2), 3)
strNSN(2) = strNSN(2) & Mid(strNSN(1), DashFscm(3), 4)
txtNSN.Value = strNSN(2)
Case 11
strNSN(2) = Left(strNSN(1), 2)
strNSN(2) = strNSN(2) & Mid(strNSN(1), NoFscm(1), 3)
strNSN(2) = strNSN(2) & Mid(strNSN(1), NoFscm(2), 4)
txtNSN.Value = strNSN(2)
End Select
DoCmd.GoToRecord , , acNext
End Sub
Private Sub cmdShowHide_Click()
Static blShow As Boolean, intCount As Integer
intCount = intCount + 1
If intCount = 1 Then
blShow = True
End If
blShow = ShowHide(blShow)
End Sub
Comment