|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have a form with a combo box and I want to use the value from this combo box in an append query in Access 2000 to be inserted into a table. I know it is quite simple but it has been giving me trouble for sometime. I use a pramaterized query and made a new parameter and appended it to the command as follows:
// The connection part Const strConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\KATO\My Documents\EgyptFalcon.mdb; Persist Security Info=False" Dim cnn As New ADODB.Connection Dim cmd As New ADODB.Command cnn.ConnectionString = strConnection cnn.Open cmd.ActiveConnection = cnn //Preparing the parameter to recieve the value of the combo //box Dim strn As String strn = Me!CustomerSelect.Value //Combo box customerSelect Dim r As ADODB.Parameter Set r = New ADODB.Parameter r.Type = adVarChar r.Name = hey r.Direction = adInput r.Size = 9 r.Value = Me!CustomerSelect.Value cmd.Parameters.Append r //The query in a command and executing it cmd.CommandText = "INSERT INTO [Transaction] ( (?) , &_[Transaction Date], [Total cost] ) SELECT Transaction.&_[Customer Name(FK)], Transaction.[Transaction Date], &_ Transaction.[Total cost] FROM [Transaction];" cmd.Execute However, it still doesnt work and I am hoping someone could tell me where I went wrong as I am still new to Visual Basic. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > How to execute an append query with parameters in VB code? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|