Question : Error 3078 can't find table

When I run the code below I get a 3078 error that it can't find the table or query.  It is happening at this line:
                strSQL = "INSERT INTO tbl_HISTORY( CLIENT_ID ) VALUES (Me.CLIENT_ID)"
                CurrentDb.Execute strSQL1, dbFailOnError

If the answer to the msgbox is yes, than I want it to create a new record in tbl_HISTORY and then display CLI_HISTORY_subform using that new record.  Can anyone tell me why I'm getting this error?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
Dim strSQL As String
 
 DoCmd.Hourglass True
 Application.Echo False, "Processing ..."
 With Me
   Select Case tabClients
     Case 0    ' First TabPage (General)
       ' Do nothing. SourceObject loaded.

     Case 1     ' Second TabPage (Academic)
        'Load source objects on Academic tab
        If .stuSchedule_subform.SourceObject <> "frm_STU_SCHEDULE" Then
          .stuSchedule_subform.SourceObject = "frm_STU_SCHEDULE"
        End If
        If .academics_subform.SourceObject <> "frm_STU_ACAD" Then
          .academics_subform.SourceObject = "frm_STU_ACAD"
        End If

     Case 2    ' Third TabPage (History)
        'Find client history.
        If DLookup("CLIENT_ID", "tbl_HISTORY", "CLIENT_ID = " & Me.CLIENT_ID) Then
           .CLI_HISTORY_subform.SourceObject = "frm_CLI_HISTORY"
        Else
           'If no history is available, prompt user to add client history.
           If MsgBox("No client history available.  Would you like to add it now?", vbYesNo) = vbYes Then
                'Insert a new record into in tbl_CLI_HISTORY
                strSQL = "INSERT INTO tbl_HISTORY( CLIENT_ID ) VALUES (Me.CLIENT_ID)"
                CurrentDb.Execute strSQL1, dbFailOnError
                'Find new record and display as subform
                If DLookup("CLIENT_ID", "tbl_HISTORY", "CLIENT_ID = " & Me.CLIENT_ID) Then
                   .CLI_HISTORY_subform.SourceObject = "frm_CLI_HISTORY"
                End If
           End If
        End If
     Case 3
         ' ...
     Case 4
         ' ...
         ' ...
   End Select
 End With
 DoCmd.Hourglass False

Answer : Error 3078 can't find table

try this


1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
rivate Sub tabClients_Change()

On Error GoTo tabClients_Change_Err
 Dim strSQL As String
 
 DoCmd.Hourglass True
 Application.Echo False, "Processing ..."
 With Me
   Select Case tabClients
     Case 0    ' First TabPage (General)
       ' Do nothing. SourceObject loaded.

     Case 1     ' Second TabPage (Academic)
        'Load source objects on Academic tab
        If .stuSchedule_subform.SourceObject <> "frm_STU_SCHEDULE" Then
          .stuSchedule_subform.SourceObject = "frm_STU_SCHEDULE"
        End If
        If .academics_subform.SourceObject <> "frm_STU_ACAD" Then
          .academics_subform.SourceObject = "frm_STU_ACAD"
        End If

     Case 2    ' Third TabPage (History)
        'Find client history.
        If DLookup("CLIENT_ID", "tbl_HISTORY", "CLIENT_ID = " & Me.CLIENT_ID) Then
           .CLI_HISTORY_subform.SourceObject = "frm_CLI_HISTORY"
        Else
           'If no history is available, prompt user to add client history.
           If MsgBox("No client history available.  Would you like to add it now?", vbYesNo) = vbYes Then
                'Insert a new record into in tbl_HISTORY
             
               with currentdb.openrecordset("tbl_History")
                    .addnew
                    !Client_ID=Me.Client_ID
                    .update
               end with

               ' strSQL = "INSERT INTO tbl_HISTORY (CLIENT_ID) VALUES (" & Me.CLIENT_ID & ")"
               ' CurrentDb.Execute strSQL1, dbFailOnError
                'Find new record and display as subform
                If DLookup("CLIENT_ID", "tbl_HISTORY", "CLIENT_ID = " & Me.CLIENT_ID) Then
                   .CLI_HISTORY_subform.SourceObject = "frm_CLI_HISTORY"
                End If
           End If
        End If
     Case 3
         ' ...
     Case 4
         ' ...
         ' ...
   End Select
 End With
 DoCmd.Hourglass False
Random Solutions  
 
programming4us programming4us