How to add bulk Item from combobox items into continues form instead of selecting one by one (1 Viewer)

Kamayo Ako

Member
Local time
Today, 19:34
Joined
May 23, 2022
Messages
89
I have i combox which row source : SELECT tblMpf.MpfID, tblMpf.Particulars FROM tblMpf ORDER BY tblMpf.MpfID;

- Is it possible that when i select one item the following all items in the list will add to the record automatically ( 1 - 20 )


Thank you so in advance for the support.


Kamayo Ako
 

Attachments

  • PMF TABLE.PNG
    PMF TABLE.PNG
    32.8 KB · Views: 54
  • PMF.png
    PMF.png
    22.4 KB · Views: 51

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:34
Joined
May 21, 2018
Messages
8,543
@arnelgp posted before me but I was going to say the same thing. Does not seem very intuitive. I would think you have a listbox and a button (add all records). However, the code would be the same either way.
Untested
Code:
Public Sub Test()
  Dim cmbo As Access.ComboBox
  Dim i As Integer
  Dim strSql As String
  Set cmbo = Me.cmboQuery
  For i = 0 To cmbo.ListCount - 1
    strSql = "Insert into tblA (fld1,fld2) values (" & cmbo.column(i, 0) & ", " & cmbo.column(i, 1) & ")"
    CurrentDb.Execute strSql
  Next i
End Sub
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 12:34
Joined
May 21, 2018
Messages
8,543
However that combo list is probably from a table somewhere. So you could more easily do a "Select Into" query.
 

Kamayo Ako

Member
Local time
Today, 19:34
Joined
May 23, 2022
Messages
89
@arnelgp posted before me but I was going to say the same thing. Does not seem very intuitive. I would think you have a listbox and a button (add all records). However, the code would be the same either way.
Untested
Code:
Public Sub Test()
  Dim cmbo As Access.ComboBox
  Dim i As Integer
  Dim strSql As String
  Set cmbo = Me.cmboQuery
  For i = 0 To cmbo.ListCount - 1
    strSql = "Insert into tblA (fld1,fld2) values (" & cmbo.column(i, 0) & ", " & cmbo.column(i, 1) & ")"
    CurrentDb.Execute strSql
  Next i
End Sub
Thank you so much sir. I will try this sir.
 

Kamayo Ako

Member
Local time
Today, 19:34
Joined
May 23, 2022
Messages
89
then you don't need a combobox and use a command button instead to add all records from
the list.
I place this transaction in subform

Link Master Fields: IDD
Link Child Fields : IDD
 

Attachments

  • SOI SUBFORM.png
    SOI SUBFORM.png
    179.3 KB · Views: 47

Users who are viewing this thread

Top Bottom