UserForm Problem

  • Thread starter Thread starter the dude
  • Start date Start date
T

the dude

Hi guys,
When I insert the data in the Userform, it's not going to fill the
database.
I am sure there are a problem with the VBA for the combobox or at least
I think..
Could you please help me???
Thanks a lot


+-------------------------------------------------------------------+
|Filename: matrix3.zip |
|Download: http://www.excelforum.com/attachment.php?postid=4828 |
+-------------------------------------------------------------------+
 
Most people will not open attachments due to the risk of viruses
or nefarious code. You should post the relevant code in the body
of your message.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"the dude"
message
news:[email protected]...
 
Hello, I didn't know that..

The code is

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Customer_Data")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
..End(xlUp).Offset(1, 0).Row

'check for an ID number
If Trim(Me.ID.Value) = "" Then
Me.ID.SetFocus
MsgBox "Please enter an ID number"
Exit Sub
End If

'copy the data to the database
With ws
ws.Cells(iRow, 1).Value = Me.ID.Value
ws.Cells(iRow, 2).Value = Me.Tier.Value
ws.Cells(iRow, 3).Value = Me.Age.Value
ws.Cells(iRow, 4).Value = Me.Spend.Value
ws.Cells(iRow, 5).Value = Me.Acc_struct.Value
ws.Cells(iRow, 6).Value = Me.cart.Value
ws.Cells(iRow, 7).Value = Me.Rank.Value
ws.Cells(iRow, 8).Value = Me.Lang.Value
ws.Cells(iRow, 9).Value = Me.Cont.Value
ws.Cells(iRow, 10).Value = Me.Vertical.Value
End With

'clear the data

Me.ID.Value = ""
Me.Tier.Value = ""
Me.Age.Value = ""
Me.Spend.Value = ""
Me.cart.Value = ""
Me.Rank.Value = ""
Me.Lang.Value = ""
Me.Cont.Value = ""
Me.Vertical.Value = ""

End Sub



Private Sub CmdClose_Click()
Unload Me
End Sub


Private Sub UserForm_Initialize()

Dim Tier As Range
Dim Age As Range
Dim Spend As Range
Dim Acc_struct As Range
Dim cart As Range
Dim Rank As Range
Dim Lang As Range
Dim Cont As Range
Dim Vertical As Range

Me.ID.SetFocus

End Sub

But it seems there is a problem and I don't know how to assign the data
to the combobox (i think this is the problem)..
What do you think?
Thanks
 
Back
Top