Hello,
Here is my code:
Everything works until the last ElseIf statement, which only insert record into the first table (DoCmd.RunSQL strAddCateg) and not the second (DoCmd.RunSQL strAddTheme).
Is it that I need to run both SQL statements at the same time? If so, how do I do that? If not, any suggestions?
when both "Me.txtAddCateg" and "Me.txtAddTheme" have a value, I want to add those values to the appropriate tables.
Here is my code:
Code:
Private Sub cmdAddNewField_Click()
Dim strAddFolderNoPath As String
Dim strAddFolderAndPath As String
Dim strAddCateg As String
Dim strAddTheme As String
strAddFolderNoPath = "INSERT INTO TblPhotosFolders(FolderName)VALUES('" & Me.txtAddFolder.Value & "')"
strAddFolderAndPath = "INSERT INTO TblPhotosFolders(FolderName,Path)VALUES('" & Me.txtAddFolder.Value & "','" & Me.txtAddFolderPath.Value & "')"
strAddCateg = "INSERT INTO TblPhotosCategories(Categories)VALUES('" & Me.txtAddCateg.Value & "')"
strAddTheme = "INSERT INTO TblPhotosThemes(ThemeName)VALUES('" & Me.txtAddTheme.Value & "')"
If Not IsNull(Me.txtAddFolder) And IsNull(Me.txtAddFolderPath) Then 'If no path was entered
DoCmd.RunSQL strAddFolderNoPath
Me.cboFolders.Requery
Me.txtAddFolder = ""
ElseIf Not IsNull(Me.txtAddFolderPath) Then
DoCmd.RunSQL strAddFolderAndPath 'If a path was entered
Me.cboFolders.Requery
Me.txtAddFolder = ""
Me.txtAddFolderPath = ""
ElseIf Not IsNull(Me.txtAddCateg) Then
DoCmd.RunSQL strAddCateg
Me.cboCateg.Requery
Me.txtAddCateg = ""
ElseIf Not IsNull(Me.txtAddTheme) Then
DoCmd.RunSQL strAddTheme
Me.cboThemes.Requery
Me.txtAddTheme = ""
ElseIf Not IsNull(Me.txtAddCateg + Me.txtAddTheme) Then
DoCmd.RunSQL strAddCateg
DoCmd.RunSQL strAddTheme
Me.cboCateg.Requery
Me.cboThemes.Requery
Me.txtAddCateg = ""
Me.txtAddTheme = ""
End If
End Sub
Everything works until the last ElseIf statement, which only insert record into the first table (DoCmd.RunSQL strAddCateg) and not the second (DoCmd.RunSQL strAddTheme).
Is it that I need to run both SQL statements at the same time? If so, how do I do that? If not, any suggestions?
when both "Me.txtAddCateg" and "Me.txtAddTheme" have a value, I want to add those values to the appropriate tables.