alpertunga65
Registered User.
- Local time
- Today, 08:01
- Joined
- Mar 15, 2013
- Messages
- 21
Hello,
I have a form (named Example) to create reports by selecting fields from tables or querries
On this form, there is a option box (name is KynkSec) with two options (Table, Query) and a combobox named as KynkTurSec.
I want to change the data source of combobox either table or query. By afterupdate, that combobox is requering the listbox "ListKynkAlan" and I can see fields of selected table or query. (That is my dream)
)
Unfortunately I can not do that. Combobox is showing only tables or both of tables and queries. But not only query.
Here is str source of my combobox:
SELECT MsysObjects.Name, MsysObjects.Type FROM MsysObjects WHERE (((MsysObjects.Type)=1) AND ((Left$([Name],1))<>"~") AND ((Left$([Name],4))<>"Msys")) OR (((MsysObjects.Type)=5) AND ((Left$([Name],1))<>"~") AND ((Left$([Name],4))<>"Msys")) ORDER BY MsysObjects.Name; That is showing both of tables and queries.
And I wrote a code for KynkSec option box;
Private Sub KynkSec_AfterUpdate()
' Populate rowsource of KynkTurSec
Dim strSQL As String
On Error GoTo HandleErr
Select Case KynkTurSec
Case 1
strSQL = "SELECT MsysObjects.Name FROM MsysObjects" _
& WHERE(((Left$([Name], 1)) <> "~") And ((MsysObjects.Type) = 1) And ((Left$([Name], 4)) <> "Msys"))
Order BY(MsysObjects.Name)
Case 2
strSQL = "SELECT MsysObjects.Name FROM MsysObjects" _
& WHERE(((Left$([Name], 1)) <> "~") And ((MsysObjects.Type) = 5) And ((Left$([Name], 4)) <> "Msys"))
Order BY(MsysObjects.Name)
Case Else
End Select
With Me!KynkTurSec
.Value = Null
.RowSource = strSQL
.Requery
.Value = .ItemData(0)
End With
ExitHere:
Exit Sub
HandleErr:
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, vbCritical, _
"Error in Example.KynkSec_AfterUpdate"
End Select
Resume ExitHere
Resume
End Sub
But this code is not working and giving a warning messsage "Sub or function is not defined"
So How can I change the source of combobox, either table or Query?
Thanks.
I have a form (named Example) to create reports by selecting fields from tables or querries
On this form, there is a option box (name is KynkSec) with two options (Table, Query) and a combobox named as KynkTurSec.
I want to change the data source of combobox either table or query. By afterupdate, that combobox is requering the listbox "ListKynkAlan" and I can see fields of selected table or query. (That is my dream)

Unfortunately I can not do that. Combobox is showing only tables or both of tables and queries. But not only query.
Here is str source of my combobox:
SELECT MsysObjects.Name, MsysObjects.Type FROM MsysObjects WHERE (((MsysObjects.Type)=1) AND ((Left$([Name],1))<>"~") AND ((Left$([Name],4))<>"Msys")) OR (((MsysObjects.Type)=5) AND ((Left$([Name],1))<>"~") AND ((Left$([Name],4))<>"Msys")) ORDER BY MsysObjects.Name; That is showing both of tables and queries.
And I wrote a code for KynkSec option box;
Private Sub KynkSec_AfterUpdate()
' Populate rowsource of KynkTurSec
Dim strSQL As String
On Error GoTo HandleErr
Select Case KynkTurSec
Case 1
strSQL = "SELECT MsysObjects.Name FROM MsysObjects" _
& WHERE(((Left$([Name], 1)) <> "~") And ((MsysObjects.Type) = 1) And ((Left$([Name], 4)) <> "Msys"))
Order BY(MsysObjects.Name)
Case 2
strSQL = "SELECT MsysObjects.Name FROM MsysObjects" _
& WHERE(((Left$([Name], 1)) <> "~") And ((MsysObjects.Type) = 5) And ((Left$([Name], 4)) <> "Msys"))
Order BY(MsysObjects.Name)
Case Else
End Select
With Me!KynkTurSec
.Value = Null
.RowSource = strSQL
.Requery
.Value = .ItemData(0)
End With
ExitHere:
Exit Sub
HandleErr:
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, vbCritical, _
"Error in Example.KynkSec_AfterUpdate"
End Select
Resume ExitHere
Resume
End Sub
But this code is not working and giving a warning messsage "Sub or function is not defined"
So How can I change the source of combobox, either table or Query?
Thanks.