query criteria based on form textbox (1 Viewer)

basilyos

Registered User.
Local time
Today, 13:03
Joined
Jan 13, 2014
Messages
252
hello


i have form1 - form2 - table1 - query1


form1 contains textbox with specific value


query1 bring data from table1


form2 (data source query1) show data from query1 (ID like the textbox on the form1)




if i run the query1 it will ask me to give input so i add any number the query will run correctly


but when i open the form i dont get any data



this what i write in the criteria section for the id
Code:
[Forms]![frm_Personal_Main]![PID]
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:03
Joined
Oct 29, 2018
Messages
21,358
Hi. Is frm_Personal_Main Form1 or Form2? What number to you enter on the Textbox of Form1?
 

basilyos

Registered User.
Local time
Today, 13:03
Joined
Jan 13, 2014
Messages
252
Hi. Is frm_Personal_Main Form1 or Form2? What number to you enter on the Textbox of Form1?




frm_Personal_Main is Form1


this form is based on another form



form 0 is contiunous form that contains the list of the staff
i double click on any staff so form1 will open and ID textbox will get the id of the stuff


form 2 is working fine without the criteria


form 2 contains the in and out times for the staff with a box to filter the times


why i want to put a criteria because when i make a search am getting the result for all the staff


it's a big database with too many tables, forms and queries i cant upload it to let you check what i have and what am asking for
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:03
Joined
Oct 29, 2018
Messages
21,358
Hi. If you can't share the db itself, can you post some screenshots instead? What is the code you're using in your Double-Click event?
 

basilyos

Registered User.
Local time
Today, 13:03
Joined
Jan 13, 2014
Messages
252
Hi. If you can't share the db itself, can you post some screenshots instead? What is the code you're using in your Double-Click event?




this is the code in the double click event
Code:
DoCmd.OpenForm "frm_Personal_Main", acNormal, , "[PID] = " & [PID]
when the personal main open i have many command button inside this form it's like a mainboard for the staff the the codes run based on the PID


one of this commands open a continuous form that show me a list for the time in and out


this form is based on query1 that show me all the staff and all the time in and out


so the is form will show me the times in and out for the specific staff because am opening the form with this code
Code:
If DCount("*", "tbl_times", "[PID] = " & [PID]) > 0 Then
    DoCmd.OpenForm "frm_times_List", acNormal, , "[PID] = " & [PID]
    Else
    MsgBox ("list is empty")
    End If
when the form open i can search a specific data using this code on after update event

Code:
    Dim strFilter As String

    If Len(Trim(Me.txt_Search.Value & vbNullString)) > 0 Then
        strFilter = "Sanction_Number Like '*" & _
            Replace(Me.txt_Search.Value, "'", "''") & _
            "*'"
        Me.Filter = strFilter
        Me.FilterOn = True
        Me.txt_Search.SetFocus
        Me.txt_Search.Value = ""
    Else
        Me.FilterOn = False
        Me.txt_Search.SetFocus
        Me.txt_Search.Value = ""
    End If
when i run the code am getting the result for all the staff





so for this reason am trying to filter the query with the staff id
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:03
Joined
Oct 29, 2018
Messages
21,358
Hi. When you double-click and the other form opens, go to the Immediate Window and try to see if there's Filter applied to it. For example:
Code:
?Forms!Form2Name.Filter
If there's something there, then try the following:
Code:
?Forms!Form2Name.FilterOn
 

basilyos

Registered User.
Local time
Today, 13:03
Joined
Jan 13, 2014
Messages
252
Hi. When you double-click and the other form opens, go to the Immediate Window and try to see if there's Filter applied to it. For example:
Code:
?Forms!Form2Name.Filter
If there's something there, then try the following:
Code:
?Forms!Form2Name.FilterOn




nothing appeared


i will try to make a similar database just to show what i want to do and i will upload it tomorrow.


thanks for your effort
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:03
Joined
Oct 29, 2018
Messages
21,358
nothing appeared

i will try to make a similar database just to show what i want to do and i will upload it tomorrow.

thanks for your effort
If nothing showed, while the form was open, then nothing got passed to it. This could mean your criteria didn't work, which is why you still see all the records displayed.
 

basilyos

Registered User.
Local time
Today, 13:03
Joined
Jan 13, 2014
Messages
252
i create a small database to upload it


but the problem is resolved i dont know how




i recreate the form in my own database everything is work fine


what could be the problem



btw the vba code i copy paste it from the old form to the new form


thanks for your effort
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:03
Joined
Oct 29, 2018
Messages
21,358
i create a small database to upload it

but the problem is resolved i dont know how

i recreate the form in my own database everything is work fine


what could be the problem

btw the vba code i copy paste it from the old form to the new form

thanks for your effort
Hi. Glad to hear you got it to work. Good luck with your project.
 

Users who are viewing this thread

Top Bottom