-2

I am working on a self created VBA form. It has submit button and takes in entries such as destination, timing and budget.

I have a excel worksheet named "bali". it consists of the destination's available airline, timing and budget.

I would like to create a method that could get the inserted destination, eg. bali, when the user clicked submit button and then match it to display and show the content of the worksheet named "bali" in another new sheet or a form.

Anyone could help me with this by providing a step by step code ?

1
  • 1
    Can you tell us what you've already tried? SuperUser is a place where we try to help those who themselves have tried to resolve something, but get stuck or run into a problem. Any examples of code you're using helps too. You improve your chances of getting a response if you provide details of what you've already tried. This does two things; 1) lets us know you are willing to put in an effort and not expect someone else to just do it for you, and 2) helps us to not suggest what you've already tried.
    – CharlieRB
    Oct 23, 2013 at 19:07

1 Answer 1

0

This is for the reference code for the simple form which i have.

Private Sub cmdCancel_Click() Unload Me End Sub

Private Sub ResetComboBox_Click() Dim ctl As Control For Each ctl In Me.Controls If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then ctl.Value = "" ElseIf TypeName(ctl) = "CheckBox" Then ctl.Value = False End If Next ctl End Sub

Private Sub SubmitComboBox_Click() If Me.DestinationComboBox.Value = "" Then MsgBox "Please choose a destination.", vbExclamation, "Travel Destination" Me.DestinationComboBox.SetFocus Exit Sub End If

 If Me.DateTextBox.Value = "" Then
    MsgBox "Please select a date.", vbExclamation, "Travel Date"
    Me.DateTextBox.SetFocus
    Exit Sub
End If

If Not IsDate(Me.DateTextBox.Value) Then
    MsgBox "The Date field must contain a date.", vbExclamation, "Travel Date"
    Me.DateTextBox.SetFocus
    Exit Sub
End If

 If Me.BudgetTextBox.Value = "" Then
    MsgBox "Please insert your budget.", vbExclamation, "Travel Budget"
    Me.BudgetTextBox.SetFocus
    Exit Sub
End If

If Not IsNumeric(Me.BudgetTextBox.Value) Then
    MsgBox "The budget field must contain number.", vbExclamation, "Travel Budget"
    Me.BudgetTextBox.SetFocus
    Exit Sub
End If

Dim RowCount As Long RowCount = Worksheets("Parameters").Range("A1").CurrentRegion.Rows.Count With Worksheets("Parameters").Range("A1") .Offset(RowCount, 0).Value = Me.DestinationComboBox.Value .Offset(RowCount, 1).Value = Me.DateTextBox.Value .Offset(RowCount, 2).Value = DateValue(Me.DateTextBox.Value) .Offset(RowCount, 3).Value = Me.BudgetTextBox.Value .Offset(RowCount, 4).Value = Me.BudgetTextBox.Value .Offset(RowCount, 5).Value = Format(Now, "dd/mm/yyyy hh:nn:ss") End With

Dim ctl As Control For Each ctl In Me.Controls If TypeName(ctl) = "TextBox" Or TypeName(ctl) = "ComboBox" Then ctl.Value = "" ElseIf TypeName(ctl) = "CheckBox" Then ctl.Value = False End If Next ctl End Sub

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .