Home > Software engineering >  Add the database data vba combobox in the form.
Add the database data vba combobox in the form.

Time:10-12

Dim oCon As New ADODB. Connection
Dim oRS As New ADODB. You
OCon. Open the Provider="Microsoft. ACE. The OLEDB. 12.0;" _
& "Data Source=" & amp; CurrentProject. Path & amp; "\ Order_DataBase. Accdb;"
Me.Com boBox1. AddItem oRS. Fields
ORS. Close
OCon. Close
The Set of oRS=Nothing
The Set oCon=Nothing

Always prompt 2047 errors.
Consult the warrior.

CodePudding user response:

Add the field type corresponding
The data binding?
For your reference

CodePudding user response:

With the attention to this problem

CodePudding user response:

1 oRS object to open (query recordset)

2 write code to oRS AddItem line by line to a column of data in the ComboBox,

CodePudding user response:

Also note this problem

CodePudding user response:

 Dim oCon As New ADODB. Connection 
Dim oRS As New ADODB. You
Dim As integer I
OCon. Open the Provider="Microsoft. ACE. The OLEDB. 12.0;" _
& "Data Source=" & amp; CurrentProject. Path & amp; "\ Order_DataBase. Accdb;"
If oRS. State<> Adstateclosed then oRS. Close
ORS. Open the "select aa from table name"
ComboBox1. Clear
For I=1 to oRS. Recordcount
ComboBox1. AddItem oRS! Aa & amp;" "
ORS. Movenext
Next I
ORS. Close
OCon. Close
The Set of oRS=Nothing
The Set oCon=Nothing
  •  Tags:  
  • VBA
  • Related