I have a weird date/null error occuring in my database. I have a form that takes in values and stores them in a table. When I load another form, I want to move certain entries into a temporary table. My code is as follows
Private Sub Form_Load()
'### Find the appropriate entry ###
tempnum = DCount("*", "JobProposal", "[Job_ID] = " & Job_ID)
'### While there are entries to move over to the temp table ###
If (tempnum > 0) Then
Me.RecordSource = "SELECT * FROM JobProposal WHERE JobProposal.Job_ID = " & Job_ID
Me.Recordset.MoveFirst
'### Loop through entries ###
For i = 1 To tempnum
Dim InvoiceType_ID, ProposalStatus_ID, JobProposal_ID As Integer
Dim QuoteAmount As Long
Dim DateRFQ_Received, DateQuoteDue, DateQuoteSubmitted, PlannedTestDate, PlannedAwardDate As String
Dim PO_number As String
'### Store old table values in temporary variables ###
PlannedTestDate = Me.Recordset.Fields("PlannedTestDate"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
PlannedAwardDate = Me.Recordset.Fields("PlannedAwardDate"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
'#### Insert values into temp table #####
DoCmd.RunSQL "INSERT INTO TempTable (fieldnames) VALUES (values)
Next i
When I first store the entries into original table, I have the following code that stores "Null" if there wasn't anyhting entered:
Me.Recordset.Fields("PlannedAwardDate"
= IIf(txtPlannedAwardDate = "", Null, txtPlannedAwardDate)
When I open the second form, and the code loops through fields, PlannedTestDate is null and is stored in the string PlannedTestDate just fine. However, when it moves down to PlannedAwardDate, which is also null, it has issues: "invalid use of null." The two fields are used the exact same throughout the database and both are entered as null. I don't know why access is fine with 4 date fields being null, but the 5th is a problem.
Also, I have my variables declared inside my loop, so theoretically they will have been re-declared once I go back through the loop, however, they retain their values from the previous loop. What's going on with this?
I know this is complicated, but does anyone have any ideas? Thanks!
Private Sub Form_Load()
'### Find the appropriate entry ###
tempnum = DCount("*", "JobProposal", "[Job_ID] = " & Job_ID)
'### While there are entries to move over to the temp table ###
If (tempnum > 0) Then
Me.RecordSource = "SELECT * FROM JobProposal WHERE JobProposal.Job_ID = " & Job_ID
Me.Recordset.MoveFirst
'### Loop through entries ###
For i = 1 To tempnum
Dim InvoiceType_ID, ProposalStatus_ID, JobProposal_ID As Integer
Dim QuoteAmount As Long
Dim DateRFQ_Received, DateQuoteDue, DateQuoteSubmitted, PlannedTestDate, PlannedAwardDate As String
Dim PO_number As String
'### Store old table values in temporary variables ###
PlannedTestDate = Me.Recordset.Fields("PlannedTestDate"
PlannedAwardDate = Me.Recordset.Fields("PlannedAwardDate"
'#### Insert values into temp table #####
DoCmd.RunSQL "INSERT INTO TempTable (fieldnames) VALUES (values)
Next i
When I first store the entries into original table, I have the following code that stores "Null" if there wasn't anyhting entered:
Me.Recordset.Fields("PlannedAwardDate"
When I open the second form, and the code loops through fields, PlannedTestDate is null and is stored in the string PlannedTestDate just fine. However, when it moves down to PlannedAwardDate, which is also null, it has issues: "invalid use of null." The two fields are used the exact same throughout the database and both are entered as null. I don't know why access is fine with 4 date fields being null, but the 5th is a problem.
Also, I have my variables declared inside my loop, so theoretically they will have been re-declared once I go back through the loop, however, they retain their values from the previous loop. What's going on with this?
I know this is complicated, but does anyone have any ideas? Thanks!