Got it working finally with the below code. I don't know that I was already doing what is right. I then used this to a Select statement and got the desired results.
Dim xdate As String
Dim queryX As Long
xdate = Format(CDate(textboxDate.Value), "mm/dd/yyyy")
queryX = Application.WorksheetFunction.CountIfs(ws.Range("H1:H50000"), xdate, ws.Range("B1:B50000"), comboCategory.Value, ws.Range("D1:D50000"), comboTerm.Value, ws.Range("E1:E50000"), textboxAmount.Value, ws.Range("F1:F50000"), comboDoctor.Value)
Select Case queryX
Case Is > 0
MsgBox "This is a possible duplicate entry! Please verify!", vbOKOnly + vbCritical + vbDefaultButton1, "Duplicate record found!"
Me.textboxDate.SetFocus
Case Else
Select Case Trim(Me.comboDoctor.Value)
Case Is = ""
Me.comboDoctor.SetFocus
MsgBox "Please select a Doctor.", vbOKOnly + vbCritical + vbDefaultButton1, "Alert!"
Case Else
ws.Cells(iRow, 1).Value = xdate
ws.Cells(iRow, 2).Value = Me.comboCategory.Value
ws.Cells(iRow, 3).Value = Me.textboxDetails.Value
ws.Cells(iRow, 4).Value = Me.comboTerm.Value
ws.Cells(iRow, 5).Value = Me.textboxAmount.Value
ws.Cells(iRow, 6).Value = Me.comboDoctor.Value
ws.Cells(iRow, 7).Value = Me.textboxAssistant.Value
MsgBox "Entry added to Outflows database", vbOKOnly + vbInformation, "Data Added"
'clear the data
Me.textboxDate.Value = ""
Me.comboCategory.Value = ""
Me.textboxDetails.Value = ""
Me.comboTerm.Value = ""
Me.textboxAmount.Value = ""
Me.comboDoctor.Value = ""
Me.textboxAssistant.Value = ""
Me.textboxDate.SetFocus
End Select
End Select
something like that. thanks for the help
Sixthsense
Bookmarks