I got this code workign doing what i want some how. Now i need to know how laugh. Is this using the control on my form? Or is this using the controlless coding? What part of it is reuseable? Can i make this into a bas file and edit it so i can easily add new client? Also if this is controlless how would i use it with my ADODC control or vise versa? Which way is best? Thanks for all your help!!
Running in circles is what I do best!
Code:
Private Sub lblAAddclient_Click()
On Error GoTo errr
Dim mCn As ADODB.Connection
Dim mRs As ADODB.Recordset
Set mCn = New ADODB.Connection
Set mRs = New ADODB.Recordset
mCn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\my work\Programs\clients.mdb"
mRs.Open "Clients", mCn, adOpenKeyset, adLockOptimistic, adCmdTable
With mRs
.AddNew
.Fields("CompanyName") = Trim(txtABName)
.Fields("FirstName") = Trim(txtAFName)
.Fields("MiddleName") = Trim(txtAMInitial)
.Fields("LastName") = Trim(txtALName)
.Fields("StreetAddress") = Trim(txtAStreet)
.Fields("City") = Trim(txtACity)
.Fields("StateOrProvince") = Trim(txtAState)
.Fields("PostalCode") = Trim(txtAZip)
.Fields("HomePhone") = Trim(txtAHome)
.Fields("WorkPhone") = Trim(txtAWork)
.Fields("MobilePhone") = Trim(txtACell)
.Fields("EmailAddress") = Trim(txtAEmail)
.Fields("Birthdate") = Trim(Format(Replace(txtABDate, "/", ""), "mm/dd/yyyy"))
.Fields("DateJoined") = Date
.Fields("PNotes") = Trim(txtAPNotes)
.Update
End With
mRs.Close
mCn.Close
txtABName = ""
txtAFName = ""
txtAMInitial = ""
txtALName = ""
txtAStreet = ""
txtACity = ""
txtAState = ""
txtAZip = ""
txtAHome = ""
txtAWork = ""
txtACell = ""
txtAEmail = ""
txtABDate = ""
txtAPNotes = ""
MsgBox "Client was successfully added!", , "Add Client"
Exit Sub
errr:
Call errorpop
End Sub
Running in circles is what I do best!