|
| |||||||||
| Tags: access, database, loop, mircosoft office suite, word |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| Insert field using a loop
Hello I have a small problem and I can not find the solution for it, yet everything seems correct to me in my code and my program. I have a form that helps me to create a switch (X port), when I create a new switch, I want to create Access to all ports of the switch in one of the tables. The number of ports is defined depends on the information into the form. Everything seems to work except that I did not create the ports and I do not understand why it is not working. Here I am trying to insert fields using a loop. Code: Private Sub Commande26_Click()
Sun cn
cn = 0
Do While cn <= Me.Nombre_de_ports.Value
Sun tr
Sun es
tst = "INSERT INTO [T_PORT.N ° Switch] VALUES ( '"
tst = tst & N ° _Switch.Value & "')"
es = "INSERT INTO [T_PORT.Port] VALUES ( '"
es = cn & & es "');"
cn = cn + 1
Loop
End Last edited by Gunner 1 : 22-01-2010 at 01:52 PM. |
|
#2
| ||||
| ||||
| Re: Insert field using a loop
Hello, I think the correct syntax is, Quote:
|
|
#3
| |||
| |||
| Re: Insert field using a loop
Hello Well I tested many things but I still have the same error flashing Quote:
Here is my code Code: Private Sub Commande21_Click()
We Error GoTo Err_Commande21_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord,, acMenuVer70
Sun swn
swn = Me.N° _swnitch.Value
Sun cp
cp = 1
Do While cp <= Me.Nombre_de_ports.Value
DoCmd.RunSQL "INSERT INTO T_PORT (Port) VALUES ( '" & & Cpte " ') WHERE [No. swnitch.Value] = & & swn"";"
cp cp = + 1
Loop
End
Exit_Commande21_Click:
Exit Sub
Err_Commande21_Click:
MsgBox Err.Description
Resume Exit_Commande21_Click
End Sub Last edited by Gunner 1 : 22-01-2010 at 01:45 PM. |
|
#4
| ||||
| ||||
| Re: Insert field using a loop
Hello, In the first code you missing a quotation mark in your RunSQL Code: Private Sub Commande21_Click()
We Error GoTo Err_Commande21_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord,, acMenuVer70
Sun swn
swn = Me.N° _swnitch.Value
Sun cp
cp = 1
Do While cp <= Me.Nombre_de_ports.Value
DoCmd.RunSQL "INSERT INTO T_PORT (Port) VALUES ( '" & & Cpte " ') WHERE [No. swnitch.Value] =" swn & & ";"
cp cp = + 1
Loop
End
Exit_Commande21_Click:
Exit Sub
Err_Commande21_Click:
MsgBox Err.Description
Resume Exit_Commande21_Click
End Sub |
|
#5
| |||
| |||
| Re: Insert field using a loop
Hello, This is my modified code, I have corrected it as you have mentioned in the above post. Code: Private Sub Commande21_Click()
We Error GoTo Err_Commande21_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord,, acMenuVer70
Sun swn
swn = Me.N° _swnitch.Value
Sun cp
cp = 1
Do While cp <= Me.same.Value
DoCmd.RunSQL "INSERT INTO T_PORT (Port) VALUES ( '" & & Cpte " ') WHERE [No. swnitch.Value] =" swn & & ";"
cp cp = + 1
Loop
End
Exit_Commande21_Click:
Exit Sub
Err_Commande21_Click:
MsgBox Err.Description
Resume Exit_Commande21_Click
End Sub |
|
#6
| ||||
| ||||
| Re: Insert field using a loop
Hello, Quote:
|
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "Insert field using a loop" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Watercooling: Single loop or Dual Loop | Akolekar | Hardware Peripherals | 3 | 21-10-2011 11:52 PM |
| Reboot Loop in Windows 7 Reboot loop and Safe mode doesn't work | mADiRAkSHii | Operating Systems | 4 | 25-01-2011 07:23 PM |
| How do I insert a signature field that replicates itself in Acrobat 9? | Lakshmibanta | Windows Software | 6 | 09-07-2010 12:26 PM |
| Multi Field value field in Microsoft Access | Erubiel | Windows Software | 3 | 20-11-2009 12:55 AM |
| Insert Link Field crashes Word 2007 Consistently | funnybroad | MS Office Support | 1 | 02-08-2007 06:20 AM |