0
Dim strSQL As String
Dim strSQL1 As String
Dim strSQL2 As String
Private Sub Command208_Click()
strSQL = "INSERT INTO PKR([Claim Number],[WANDFNF],[WANDOUP],[WANDEA]) VALUES ([Forms]![Form Level].[Form]![Claim Number],[Forms]![Form Level].[Form]![Wand_cmb1],[Forms]![Form Level].[Form]![Wand_cmb2],[Forms]![Form Level].[Form]![Wand_txt2])"
strSQL1 = "INSERT INTO PKR([TranFNF],[TranOUP],[TranEA]) VALUES ([Forms]![Form Level].[Form]![Tran_cmb1],[Forms]![Form Level].[Form]![Tran_cmb2],[Forms]![Form Level].[Form]![Tran_txt2])"
strSQL2 = "INSERT INTO PKR([DRFNF],[DROUP],[DREA]) VALUES ([Forms]![Form Level].[Form]![DR_cmb1],[Forms]![Form Level].[Form]![DR_cmb2],[Forms]![Form Level].[Form]![DR_txt2])"
 
 DoCmd.SetWarnings False
    DoCmd.RunSQL strSQL
    DoCmd.SetWarnings True
 DoCmd.SetWarnings False
    DoCmd.RunSQL strSQL1
    DoCmd.SetWarnings True
 DoCmd.SetWarnings False8
    DoCmd.RunSQL strSQL2
    DoCmd.SetWarnings True
End Sub

Here i have build a button command_208 to get data from text/combo boxes on a form to different table PKR. I am able to get data for 1st query but not getting any data for the strSQL1 & strSQL2.

braX
  • 11,506
  • 5
  • 20
  • 33
  • You want to insert 3 records? Why do you need to use VBA instead of BOUND form? Really only need one pair of SetWarnings. Why does the last one show `False8`? Leave warnings on for testing and see what message you get. – June7 Nov 15 '22 at 16:54
  • Thanks braX, but i was trying to get these values to diffrent tables and now i am able to. BTW False8 was typing error :P – Shubham rawat Nov 16 '22 at 12:07
  • "to different tables" - but each SQL references same table. – June7 Nov 16 '22 at 17:01

0 Answers0