📄 frmproductsuomae.frm
字号:
VERSION 5.00
Begin VB.Form frmProductsUOMAE
BorderStyle = 1 'Fixed Single
Caption = "Edit Entry"
ClientHeight = 2610
ClientLeft = 45
ClientTop = 435
ClientWidth = 5130
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2610
ScaleWidth = 5130
StartUpPosition = 2 'CenterScreen
Begin VB.TextBox txtAddCharges
Alignment = 1 'Right Justify
Height = 285
Left = 1560
TabIndex = 1
Top = 840
Width = 1185
End
Begin VB.ComboBox cboGroupings
Height = 315
ItemData = "frmProductsUOMAE.frx":0000
Left = 1560
List = "frmProductsUOMAE.frx":000A
TabIndex = 2
Top = 1200
Width = 2685
End
Begin VB.TextBox txtEntry
Height = 285
Left = 1560
MaxLength = 10
TabIndex = 0
Tag = "Unit"
Top = 480
Width = 3390
End
Begin VB.CommandButton cmdSave
Caption = "Save"
Default = -1 'True
Height = 315
Left = 2220
TabIndex = 3
Top = 1995
Width = 1335
End
Begin VB.CommandButton cmdCancel
Caption = "Cancel"
Height = 315
Left = 3660
TabIndex = 4
Top = 1995
Width = 1335
End
Begin VB.CommandButton cmdUsrHistory
Caption = "Modification History"
Height = 315
Left = 150
TabIndex = 5
Top = 1995
Width = 1680
End
Begin Inventory.ctrlLiner ctrlLiner1
Height = 30
Left = 165
TabIndex = 6
Top = 1800
Width = 4815
_ExtentX = 10213
_ExtentY = 53
End
Begin VB.Label Label2
Alignment = 1 'Right Justify
Caption = "Additional Charges"
Height = 285
Left = 60
TabIndex = 9
Top = 840
Width = 1425
End
Begin VB.Label Label1
Alignment = 1 'Right Justify
Caption = "Groupings"
Height = 285
Left = 240
TabIndex = 8
Top = 1215
Width = 1245
End
Begin VB.Label Labels
Alignment = 1 'Right Justify
Caption = "Unit"
Height = 285
Left = 285
TabIndex = 7
Top = 480
Width = 1215
End
End
Attribute VB_Name = "frmProductsUOMAE"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public State As FormState 'Variable used to determine on how the form used
Public PK As Long 'Variable used to get what record is going to edit
Public srcText As TextBox 'Used in pop-up mode
Dim HaveAction As Boolean 'Variable used to detect if the user perform some action
Dim RS As New Recordset
Private Sub DisplayForEditing()
On Error GoTo err
With RS
txtEntry.Text = .Fields("Unit")
cboGroupings.Text = .Fields("Groupings")
txtAddCharges.Text = .Fields("AddCharges")
End With
Exit Sub
err:
If err.Number = 94 Then Resume Next
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub ResetFields()
clearText Me
txtEntry.SetFocus
End Sub
Private Sub cmdSave_Click()
If State = adStateAddMode Then
RS.AddNew
RS.Fields("DateAdded") = Now
RS.Fields("AddedByFK") = CurrUser.USER_PK
Else
RS.Fields("DateModified") = Now
RS.Fields("LastUserFK") = CurrUser.USER_PK
End If
'Phill 2:12
With RS
.Fields("Unit") = txtEntry.Text
.Fields("Groupings") = cboGroupings.Text
.Fields("AddCharges") = txtAddCharges.Text
.Update
End With
HaveAction = True
If State = adStateAddMode Then
MsgBox "New record has been successfully saved.", vbInformation
If MsgBox("Do you want to add another new record?", vbQuestion + vbYesNo) = vbYes Then
ResetFields
Else
Unload Me
End If
Else
MsgBox "Changes in record has been successfully saved.", vbInformation
Unload Me
End If
End Sub
Private Sub cmdUsrHistory_Click()
On Error Resume Next
Dim tDate1 As String
Dim tDate2 As String
Dim tUser1 As String
Dim tUser2 As String
tDate1 = Format$(RS.Fields("DateAdded"), "MMM-dd-yyyy HH:MM AMPM")
tDate2 = Format$(RS.Fields("DateModified"), "MMM-dd-yyyy HH:MM AMPM")
tUser1 = getValueAt("SELECT PK,CompleteName FROM tbl_SM_Users WHERE PK = " & RS.Fields("AddedByFK"), "CompleteName")
tUser2 = getValueAt("SELECT PK,CompleteName FROM tbl_SM_Users WHERE PK = " & RS.Fields("LastUserFK"), "CompleteName")
MsgBox "Date Added: " & tDate1 & vbCrLf & _
"Added By: " & tUser1 & vbCrLf & _
"" & vbCrLf & _
"Last Modified: " & tDate2 & vbCrLf & _
"Modified By: " & tUser2, vbInformation, "Modification History"
tDate1 = vbNullString
tDate2 = vbNullString
tUser1 = vbNullString
tUser2 = vbNullString
End Sub
Private Sub Form_Load()
RS.CursorLocation = adUseClient
RS.Open "SELECT * FROM Unit WHERE UnitID = " & PK, CN, adOpenStatic, adLockOptimistic
'Check the form state
If State = adStateAddMode Then
Caption = "Create New Entry"
cmdUsrHistory.Enabled = False
Else
Caption = "Edit Entry"
DisplayForEditing
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
If HaveAction = True Then
If State = adStateAddMode Or adStateEditMode Then
frmProductsUOM.RefreshRecords
End If
End If
Set frmProductsUOMAE = Nothing
End Sub
Private Sub txtAddCharges_KeyPress(KeyAscii As Integer)
KeyAscii = isNumber(KeyAscii)
End Sub
Private Sub txtAddCharges_Validate(Cancel As Boolean)
txtAddCharges.Text = toMoney(txtAddCharges.Text)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -