Hi all-
not sure if this is the correct forum to post this, but here it goes. I have a form called order entry for well entering orders. A user types part number into a textbox, and my code finds all related parts (for the assembly), and inserts them into a temporary table, linked to a listbox on my form. The user can then go through each line item and decide if we need to manufacture the part, or if it is in inventory, give it an order number if it needs to be made, add notes, etc. to each line item. When the user clicks on the line item in the listbox, it populates the info for that line item in textboxes on the same form, and when the user clicks save, it saves it back to the temp table and refreshes the listbox. After all line items are correct, a user clicks a button to append them to the orders table. Here's my problem. If a user leaves a field blank (pertaining to line item), and clicks save, they get invalid use of null 94. Ideally, a field would be allowed to be left blank and the sql statement would insert null into that field. I know there has to be a way to do this! Here is my code for when the save button is clicked. Any help would be awesome! Thanks
not sure if this is the correct forum to post this, but here it goes. I have a form called order entry for well entering orders. A user types part number into a textbox, and my code finds all related parts (for the assembly), and inserts them into a temporary table, linked to a listbox on my form. The user can then go through each line item and decide if we need to manufacture the part, or if it is in inventory, give it an order number if it needs to be made, add notes, etc. to each line item. When the user clicks on the line item in the listbox, it populates the info for that line item in textboxes on the same form, and when the user clicks save, it saves it back to the temp table and refreshes the listbox. After all line items are correct, a user clicks a button to append them to the orders table. Here's my problem. If a user leaves a field blank (pertaining to line item), and clicks save, they get invalid use of null 94. Ideally, a field would be allowed to be left blank and the sql statement would insert null into that field. I know there has to be a way to do this! Here is my code for when the save button is clicked. Any help would be awesome! Thanks
Code:
Dim intTMPID As Integer
Dim intCUSTID As Integer
Dim strSHOP As String
Dim strREV As String
Dim intQTY As Integer
Dim strNOTES As String
intTMPID = Me.lst_Orders.Value
intCUSTID = Me.cbo_Customer.Value
strSHOP = Me.txt_ShopOrder.Value
strREV = Me.txt_Rev.Value
intQTY = Me.txt_Quantity.Value
strNOTES = Me.txt_Notes.Value
Dim strSQL As String
strSQL = "UPDATE tbl_TempOrders" _
& " SET ShopOrder = '" & strSHOP & "'" & ", Customer = " & intCUSTID & ", Rev = '" & strREV & "'" & ", Quantity = " & intQTY & ", Notes = '" & strNOTES & "'" _
& " WHERE TmpOrderId=" & intTMPID & ";"
CurrentDb.Execute strSQL
Me.lst_Orders.Requery