Hi, I have access application allowing users to add accounts, currently the program add,update,deletes information from a linked mdb table. What I can't figure out is how to also add a link to mysql database in order have information in both the mdb and mysql update-to-date.
I created a link to mysql table (called accounts1), and tried to add code to create a dao.recordset but am completely lost.
Also in my Insert query for the last field company, on my access form I have check boxes but on mysql table has numbers associated with each type of company, how do I converted the checkbox marked to a company. (for exmaple if checkbox is marked for 'Fed mutual' the company is assigned '2' on the mysql databse)
What I have tried:
<pre>Private Sub AddCmdButon_Click()
ValidateCmdButton_Click
If Me.ProcessFlagTBox = False Then
Dim dbs1 As Database
Dim aTable As Recordset
Dim srchKey As String
Set dbs1 = CurrentDb
Set aTable = dbs1.OpenRecordset("Accounts", dbOpenDynaset)
srchKey = "[ShortDescription] = '" & Me.ShortDescriptionTBox & "'"
aTable.FindFirst srchKey
Dim db As DAO.Database
Dim rstAccounts As DAO.Recordset
Dim strSQL As String
Set db = CurrentDb
strSQL = strSQL = INSERT INTO accounts1 ('ShortDesc', 'Description', 'Account', 'Region', 'CostCode', 'LOB', 'State', 'StateReq', 'NAICPLS', 'Company')
VALUES ('UCase(Me.ShortDescriptionTBox)', 'UCase(Me.DescriptionTBox)', 'UCase(Me.MajorAccountTBox)', 'UCase(Me.DivRegionTBox)', 'UCase(Me.CostCodeTBox)',
'UCase(Me.LOBTBox)', 'UCase(Me.StateTBox)', 'Me.[NAIC-PageLineSubLineTBox]', '????';
Set rstAccounts = db.OpenRecordset(strSQL)
If aTable.NoMatch = True Then
' Record not found (Add it)
aTable.AddNew
aTable![ShortDescription] = UCase(Me.ShortDescriptionTBox)
aTable![Description] = UCase(Me.DescriptionTBox)
aTable![MajorAccount] = UCase(Me.MajorAccountTBox)
aTable![DivReg] = UCase(Me.DivRegionTBox)
aTable![CostCenter] = UCase(Me.CostCodeTBox)
aTable.Update
MsgBox "The record was successfully added.", vbOKOnly, "INFORMATIONAL MESSAGE BOX"
ClearCmdButton_Click
Me.DescrComboBoxCBox.Requery
Me.DescrComboBoxCBox1.Requery
Else
' Record found (Duplicate)
MsgBox "The record already exist on file. ", vbOKOnly, "INFORMATIONAL MESSAGE BOX"
End If
aTable.Close
dbs1.Close
End If
End Sub