kovan
Sep 11th, 2000, 08:03 AM
what does everyone use when adding a new record to a table?
editing a new record?
just wondering if SELECT is BAD for adding new records
like i have done in the following..
i tend to use SELECT * when adding new records to my tables.. dont know how bad this is
if anyone has a better idea
please modify the following code with new way and reasons why.. thank you
SQL = "SELECT * " & _
"FROM Clientcode " & _
"WHERE clientcode= " & Format(txtClientCode.Text, "000")
With NewClientCodeRecords
Call CloseIfOpen(NewClientCodeRecords)
.Open SQL, MeterInfo, adOpenKeyset, adLockOptimistic
If Not .EOF Then
MsgBox "This client code exists,please enter new client code"
txtClientCode.SetFocus
.Close
Exit Sub
End If
'addes the information to the client code table
.AddNew
If Not Trim(txtClientCode.Text) = "" Then !ClientCode = txtClientCode.Text
If Not Trim(txtClientName.Text) = "" Then !ClientName = txtClientName.Text
If Not Trim(txtContact.Text) = "" Then !ContactName = txtContact.Text
If Not Trim(txtAddress.Text) = "" Then !Address = txtAddress.Text
If Not Trim(txtPhone.Text) = "" Then !Phone = txtPhone.Text
If Not Trim(txtCity.Text) = "" Then !City = txtCity.Text
If Not Trim(txtProvince.Text) = "" Then !Province = txtProvince.Text
If Not Trim(txtPostalCode.Text) = "" Then !PostalCode = txtPostalCode.Text
If Not Trim(txtContractorNum.Text) = "" Then !ContractorNum = txtContractorNum.Text
.Update
.Close
End With
editing a new record?
just wondering if SELECT is BAD for adding new records
like i have done in the following..
i tend to use SELECT * when adding new records to my tables.. dont know how bad this is
if anyone has a better idea
please modify the following code with new way and reasons why.. thank you
SQL = "SELECT * " & _
"FROM Clientcode " & _
"WHERE clientcode= " & Format(txtClientCode.Text, "000")
With NewClientCodeRecords
Call CloseIfOpen(NewClientCodeRecords)
.Open SQL, MeterInfo, adOpenKeyset, adLockOptimistic
If Not .EOF Then
MsgBox "This client code exists,please enter new client code"
txtClientCode.SetFocus
.Close
Exit Sub
End If
'addes the information to the client code table
.AddNew
If Not Trim(txtClientCode.Text) = "" Then !ClientCode = txtClientCode.Text
If Not Trim(txtClientName.Text) = "" Then !ClientName = txtClientName.Text
If Not Trim(txtContact.Text) = "" Then !ContactName = txtContact.Text
If Not Trim(txtAddress.Text) = "" Then !Address = txtAddress.Text
If Not Trim(txtPhone.Text) = "" Then !Phone = txtPhone.Text
If Not Trim(txtCity.Text) = "" Then !City = txtCity.Text
If Not Trim(txtProvince.Text) = "" Then !Province = txtProvince.Text
If Not Trim(txtPostalCode.Text) = "" Then !PostalCode = txtPostalCode.Text
If Not Trim(txtContractorNum.Text) = "" Then !ContractorNum = txtContractorNum.Text
.Update
.Close
End With