C
cjjoo
i got a user form where the end user can just input the datas from
list of datas. the user form has a drop down box but the problem i
that there is a limit to the number of characters i input into th
first drop down box.
can another take a look at the code and tell me what is wrong?
Private Sub cmdAdd_Click()
Dim iRow As Long
'find first empty row in database
iRow = wksPartsData.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.cboPart.Value) = "" Then
Me.cboPart.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If
'copy the data to the database
With wksPartsData
.Cells(iRow, 1).Value = Me.cboPart.Value
.Cells(iRow, 2).Value = Me.cboLocation.Value
.Cells(iRow, 3).Value = Me.txtDate.Value
.Cells(iRow, 4).Value = Me.txtQty.Value
End With
'clear the data
Me.cboPart.Value = ""
Me.cboLocation.Value = ""
Me.txtDate.Value = Format(Date, "Medium Date")
Me.txtQty.Value = 1
Me.cboPart.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim cPart As Range
Dim cLoc As Range
For Each cPart In wksLookupLists.Range("PartIDList")
With Me.cboPart
.AddItem cPart.Value
.List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
End With
Next cPart
For Each cLoc In wksLookupLists.Range("LocationList")
With Me.cboLocation
.AddItem cLoc.Value
.List(.ListCount - 1, 1) = cLoc.Offset(0, 1).Value
End With
Next cLoc
Me.txtDate.Value = Format(Date, "Medium Date")
Me.txtQty.Value = 1
Me.cboPart.SetFocus
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button!"
End If
End Su
list of datas. the user form has a drop down box but the problem i
that there is a limit to the number of characters i input into th
first drop down box.
can another take a look at the code and tell me what is wrong?
Private Sub cmdAdd_Click()
Dim iRow As Long
'find first empty row in database
iRow = wksPartsData.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a part number
If Trim(Me.cboPart.Value) = "" Then
Me.cboPart.SetFocus
MsgBox "Please enter a part number"
Exit Sub
End If
'copy the data to the database
With wksPartsData
.Cells(iRow, 1).Value = Me.cboPart.Value
.Cells(iRow, 2).Value = Me.cboLocation.Value
.Cells(iRow, 3).Value = Me.txtDate.Value
.Cells(iRow, 4).Value = Me.txtQty.Value
End With
'clear the data
Me.cboPart.Value = ""
Me.cboLocation.Value = ""
Me.txtDate.Value = Format(Date, "Medium Date")
Me.txtQty.Value = 1
Me.cboPart.SetFocus
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim cPart As Range
Dim cLoc As Range
For Each cPart In wksLookupLists.Range("PartIDList")
With Me.cboPart
.AddItem cPart.Value
.List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
End With
Next cPart
For Each cLoc In wksLookupLists.Range("LocationList")
With Me.cboLocation
.AddItem cLoc.Value
.List(.ListCount - 1, 1) = cLoc.Offset(0, 1).Value
End With
Next cLoc
Me.txtDate.Value = Format(Date, "Medium Date")
Me.txtQty.Value = 1
Me.cboPart.SetFocus
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
MsgBox "Please use the button!"
End If
End Su