Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results in SubForm:

Status
Not open for further replies.

RustyDWO

Technical User
Mar 14, 2002
65
NL
I created a SearchForm with a SubForm (only) for the results. In the Form there are 6 argument that may be filled in for the actual search.
To actually start the search there is a button. On the Click of this button I would like a script is run.
Digging in several sites I came up with the following:
Table to look into: Organisaties, filled in as SearchForm's RecordSource at properties
Field to check: Plaats, Categorie and 4 more not included yet
Search argument names: Plaats_zoekkeuze, Cat_zoekkeuze
SubForm name: Zoekresultaat

Private Sub Zoekknop_Click()
Dim strWhere As String
strWhere = "1=1"

If Not IsNull(Me!Plaats_zoekkeuze) Then
strWhere = strWhere & " And [Plaats] = '" & Me!Plaats_zoekkeuze & "'"
End If

If Not IsNull(Me!Cat_zoekkeuze) Then
strWhere = strWhere & " And [Categorie] = '" & Me!Cat_zoekkeuze & "'"
End If

Me![Zoekresultaat].Form.RecordSource = strWhere

End Sub

Runtime error 3078; can't find input table or query!
At debug the first Me!-line is yellow and part after = seems to be the problem?
So as far as I can understand the actual found data can't be placed in the SubForm for whatever reason.

Can anyone help me complete this script succesfully?
Thanks for the effort

For anyone to have a closer look here is the zip for Access97:
 
'me' is the active subform. YOur data does not appear to be in the 'me'form. Is that the case? If that is true, you must point to the me. data. Place some strategic MSGBOX's in the sub and see what they see. For iinstance, when you change your querey string, print the query string with megbox.

rollie@bwsys.net

Taht way, you can do your own debug!!!
 
Rollie,

Sorry, I'm not that familiar with programming and I don't understand what you mean with pointing to the me.data.
The form and sub are both on the screen at the same time.
The form is linked to the table en the arguments are in the the form.
The subform should display the result.

????

RustyDWO
 
They cannot both have focus. Each has a distiinct name. The main might be forms![Main1] and the sub might be forms![Main1]![SData]. the one that has the focus is also alias'd as 'me.' Thus if you did an event on update and placed msgbox me.name as the code, you would get a popup[ box that tells you the name of the one then active. Do that to help see what cooks.

Rollie
 
To everybody who understands my problem,

I think I'm lost a bit.
Somewhere I read that comboboxes can't be used for these search argument due the the fact that they are bound to a record source. Is this correct?
What are my alternatives whitout to many changes in my form.

I made some changes to the above as advices by others but it still doen't work.

Private Sub Zoekknop_Click()
Dim strSQL As String
Dim strWhere As String
strSQL = "Select * From Organisaties"

If Not IsNull(Me!Plaatszoek) Then
strWhere = strWhere & " And [Plaats] = '" & Me!Plaatszoek & "'"
End If

If Not IsNull(Me!Catzoek) Then
strWhere = strWhere & " And [Categorie] = '" & Me!Catzoek & "'"
End If

strSQL = strSQL & strWhwere & ";"

Me.Zoekresultaat.Form.RecordSource = strSQL

End Sub


For anyone to have a closer look here is the zip for Access97:
The final result should not have a menu-bar!
 
If the combo box has a recordsource, it [laces what it finds in that field. Clear the field and the combobox just points to thye data in the bound field of the box. Send me an email and I will send you a small mdb that shows how to use the combo box for a search process. If you were to do an onclick of the coombobox and put msgbox me.combo1 (or whatever number your box is) it will tell you what it points to.

Rollie E
 
I think I'm lost a bit.
Somewhere I read that comboboxes can't be used for these search argument due the the fact that they are bound to a record source. Is this correct?
What are my alternatives whitout to many changes in my form.

I made some changes to the above as advices by others but it still doen't work.

Private Sub Zoekknop_Click()
Dim strSQL As String
Dim strWhere As String
strSQL = "Select * From Organisaties"

If Not IsNull(Me!Plaatszoek) Then
strWhere = strWhere & " And [Plaats] = '" & Me!Plaatszoek & "'"
End If

If Not IsNull(Me!Catzoek) Then
strWhere = strWhere & " And [Categorie] = '" & Me!Catzoek & "'"
End If

strSQL = strSQL & strWhwere & ";"

Me.Zoekresultaat.Form.RecordSource = strSQL

End Sub


For anyone to have a closer look here is the zip for Access97:
The final result should not have a menu-bar!
 
Rollie,

Sorry for the double input but MSIE likes to get things from memory and confused me.

e-mail = desli.marcrust@wanadoo.nl

Looking forward
Tanks

RustyDWO
 
Can anybody tell me how to email somebody from this site with just the name?

RustyDWO
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top