Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

There Has to Be a Better Way to Code This???

Status
Not open for further replies.

mbarnett

MIS
Jun 15, 2003
123
US
Hi ,

I have a main user form and based on input dates and combo box selections the below code will open up a query. My problem is if no one inputs a date the code should tekll ya to input a date...This only works when you first open the form..i suspect the code is not written that well and my skills are not that good to fix....any ideas...

Private Sub cmdReportableEdits_Click()

If ([txtstartdate_edits].Value = "") Then
MsgBox "You must enter a date."
Exit Sub
End If

If ([txtEndDate_edits].Value = "") Then
MsgBox "You must enter a date."
Exit Sub
End If

If IsNull([cmboBookName_Edits]) Then
MsgBox "You must select book."
Exit Sub
End If

If Me!cmboBookName_Edits.Value = "Multis" Then
Call GetMultisRE
End If

If Me!cmboBookName_Edits.Value = "Exotics" Then
Call GetExoticsRE
End If

If Me!cmboBookName_Edits.Value = "AI" Then
Call GetAIRE
End If
If Me!cmboBookName_Edits.Value = "PrePay" Then
Call GetPPRE
End If

If Me!cmboBookName_Edits.Value = "Flow" Then
Call GetFlowRE
End If
End Sub
 
Yiu may consider something like this:
If Not IsDate([txtstartdate_edits]) Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
For multiple If's...

Select Case Me!cmboBookName_Edits.Value
Case "Multis'
Call GetMultisRE
...
End Select
 
i would change this block of code to
Code:
If Me!cmboBookName_Edits.Value = "Multis" Then
    Call GetMultisRE
 End If

 If Me!cmboBookName_Edits.Value = "Exotics" Then
    Call GetExoticsRE
 End If
 
  If Me!cmboBookName_Edits.Value = "AI" Then
    Call GetAIRE
 End If
  If Me!cmboBookName_Edits.Value = "PrePay" Then
    Call GetPPRE
 End If
 
 If Me!cmboBookName_Edits.Value = "Flow" Then
    Call GetFlowRE
 End If


eval ("get" & Me!cmboBookName_Edits & "ie()")

and change all the gets...ie to functions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top