Hey Guys,
Having an issue with what I thought would be a simple couple lines of code, but I keep getting kicked a run-time error (object required), and I can't figure out why.
Basically I have a form where a user has selected a couple values from a dropdown element, and entered a few other text values into the form. I am then trying to grab the values and append them to a table. Not sure what is going wrong- any help or guidance you can provide would be greatly appreciated.
Thanks again so much, and please let me know if any other information would be useful.
Cheers!
Having an issue with what I thought would be a simple couple lines of code, but I keep getting kicked a run-time error (object required), and I can't figure out why.
Basically I have a form where a user has selected a couple values from a dropdown element, and entered a few other text values into the form. I am then trying to grab the values and append them to a table. Not sure what is going wrong- any help or guidance you can provide would be greatly appreciated.
Code:
Private Sub btnSubmitInputVendorPerformanceForm_Click() 'Button Is part of frmInputVendorPerformance
Dim ValueCheck As Integer 'Increments to make sure no errors in entry
Dim ErrorShow As String
Dim YesorNoAnswerToMessageBox As String
Dim QuestionToMessageBox As String
Dim DeliveryRate As String
Dim FailedBounced As String
Dim FailRate As String
Dim OpenRate As String
Dim ClickRate As String
Dim NoResponse As String
Dim NoResponseRate As String
Dim DropOutRate As String
Dim PureIncidenceRate As String
Dim PureTerminateRate As String
Dim CommunityDuplicateRate As String
Dim suspiciousRate As String
Dim OtherBackEndScreenoutRate As String
Dim FinalIncidenceRate As String
Dim NotInvitedButQualified As String
Dim ConversionRate As String
Dim CostPerLogin As String
Dim CostPerResponse As String
Dim CostPerInvited As String
Dim TargetingPerformanceCostPerMember As String
Dim additionalCostPerMember As String
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Dim sqry As String
Dim CurrentVersion As String
ValueCheck = 0 'Sets value-check to default no-error value
ErrorShow = ""
If lstSelectProject.Value = "" Then
MsgBox "Please select a project.", vbCritical
Exit Sub
End If
'handling for exception: validation costs only
Dim rs_ex As ADODB.Recordset
Set rs_ex = New ADODB.Recordset
sqry = "SELECT Type FROM tblVendors WHERE VendorID = " & inputAddVendorPerformanceVendor.Value & ";"
rs_ex.Open sqry, CurrentProject.Connection, adOpenStatic
If rs_ex!Type = "Validation" Then
If IsNumeric(inputTotalProjectCost.Value) = False Or IsNull(inputTotalProjectCost.Value) Or inputTotalProjectCost.Value < 0 Then 'If number is not valid...
ValueCheck = ValueCheck + 1
ErrorShow = ErrorShow + "Total Project Cost" + vbNewLine
End If
If IsNumeric(inputFixedProjectCost.Value) = False Or IsNull(inputFixedProjectCost.Value) Or inputFixedProjectCost.Value < 0 Then 'If number is not valid...
ValueCheck = ValueCheck + 1
ErrorShow = ErrorShow + "Fixed Project Cost" + vbNewLine
End If
If ValueCheck = 0 Then
' ERROR KICKED BELOW
[B] sqry = _
"INSERT INTO tblVendorPerformance (ProjectRefNum, VendorID, TotalProjectCost, FixedProjectCost, Notes) " & _
"VALUES ('" & inputAddVendorPerformanceProject.Value & "', " & inputAddVendorPerformanceVendor & ", " & _
inputTotalProjectCost.Value & ", " & inputFixedProjectCost.Value & ", '" & inputNotes.Value & " ');"[/B]
DoCmd.SetWarnings False
DoCmd.RunSQL sqry
DoCmd.SetWarnings True
Thanks again so much, and please let me know if any other information would be useful.
Cheers!
Last edited: