Hi, i have a module like this:
which i call with a button on my form:
but when i leave one of the field blank i get an error, this is because its trying to save something when there is nothing in the field to save.
so how can i get it to save just the fields that are populated in my form, i dont rearly want to have to setup default values as this will just waste space in saving null events
best regards
Code:
Public Function Savea(VBText157 As String, VBDigitised_by As String, VBTeam As String, VBPRefNumber As String)
' open a connection to the connection object
Set cn = CurrentProject.Connection
' initialise the recordset object
Set rs = New ADODB.Recordset
' using the recordset object
With rs
.Open "TBL_Main_test", cn, adOpenStatic, adLockOptimistic ' open it
.AddNew ' prepare to add a new record
.Fields("Type_DB") = VBText157
.Fields("User_ID") = VBDigitised_by
.Fields("team") = VBTeam
.Fields("Pack_Ref_Number") = VBPRefNumber
.Update ' update the table
.Close ' close the recordset connection
End With
End Function
which i call with a button on my form:
Code:
Private Sub Command257_Click()
Call Savea(Text157, Digitised_by, team, PRefNumber)
End Sub
but when i leave one of the field blank i get an error, this is because its trying to save something when there is nothing in the field to save.
so how can i get it to save just the fields that are populated in my form, i dont rearly want to have to setup default values as this will just waste space in saving null events
best regards
Last edited: