G
George Papadopoulos
Hello everybody
I have a form with a push-button on it. I need another form to open when I
press that button. The second form contains a list box which is to be
populated by running a programmatic query. Firstly, I show the code I am
using for the on_click handler of the button.
Private Sub List_spares_Click()
On Error GoTo Err_cmdGoHere_Click
Dim stDocName As String
stDocName = "LISTA_ANTALLAKTIKWN"
DoCmd.OpenForm stDocName, OpenArgs:=Me.[Kwdikos_episkeyhs]
Exit_cmdGoHere_Click:
Exit Sub
Err_cmdGoHere_Click:
MsgBox Err.Description
Resume Exit_cmdGoHere_Click
End Sub
The code opens the second form and passes a parameter to the second form.
The after_update handler for the second form is shown below :
Private Sub Form_Load()
Dim dbEPEMBATHS As Database
Dim rsSpares As Recordset
Dim Kwdikos As Long
Dim objvar As Object
If Not IsNull(Me.OpenArgs) Then
Kwdikos = Me.OpenArgs
End If
' Set dbLib to the current database
Set dbEPEMBATHS = CurrentDb
' Create a query
strselect = "Select * FROM ANTALLAKTIKA WHERE 'Kwdikos_episkeyhs =
Kwdikos'"
Set rsSpares = dbEPEMBATHS.OpenRecordSet(strselect)
For Each objvar In rsSpares
[Forms].[LISTA_ANTALLAKTIKWN].[Spares_List].AddItem objvar
Next
End Sub
When I run the code I get the error 'The function is not supported by this
type of object'. I believe the problematic line is the one where I add new
items.
The general idea is that I want to add each row of the selected recordset
to the listbox. What am i missing?
Thanks in advance
George Papadopoulos
I have a form with a push-button on it. I need another form to open when I
press that button. The second form contains a list box which is to be
populated by running a programmatic query. Firstly, I show the code I am
using for the on_click handler of the button.
Private Sub List_spares_Click()
On Error GoTo Err_cmdGoHere_Click
Dim stDocName As String
stDocName = "LISTA_ANTALLAKTIKWN"
DoCmd.OpenForm stDocName, OpenArgs:=Me.[Kwdikos_episkeyhs]
Exit_cmdGoHere_Click:
Exit Sub
Err_cmdGoHere_Click:
MsgBox Err.Description
Resume Exit_cmdGoHere_Click
End Sub
The code opens the second form and passes a parameter to the second form.
The after_update handler for the second form is shown below :
Private Sub Form_Load()
Dim dbEPEMBATHS As Database
Dim rsSpares As Recordset
Dim Kwdikos As Long
Dim objvar As Object
If Not IsNull(Me.OpenArgs) Then
Kwdikos = Me.OpenArgs
End If
' Set dbLib to the current database
Set dbEPEMBATHS = CurrentDb
' Create a query
strselect = "Select * FROM ANTALLAKTIKA WHERE 'Kwdikos_episkeyhs =
Kwdikos'"
Set rsSpares = dbEPEMBATHS.OpenRecordSet(strselect)
For Each objvar In rsSpares
[Forms].[LISTA_ANTALLAKTIKWN].[Spares_List].AddItem objvar
Next
End Sub
When I run the code I get the error 'The function is not supported by this
type of object'. I believe the problematic line is the one where I add new
items.
The general idea is that I want to add each row of the selected recordset
to the listbox. What am i missing?
Thanks in advance
George Papadopoulos