I have a main form that contains a Search txtbox that when cmdSearch is click, opens another form that contains a list box of items. what i want to do is sort this items by whatever letter is entered in the search txtbox and when clicking a selection from the list box, go to main form and fill in the areas with the selected item from the list box...can anyone help with this issue? -- need help
![]() |
0 |
![]() |
Each form can refer to the contents of a control on the other form. On your popup form, pull the contents from the Search textbox to sort your list. These newsgroups have lots of examples of referring to controls on other forms. For the second case, I would have the second form set a global (application-level) variable that the first form can then pick up immediately after the second form closes and use to locate the appropriate record. Create a module that contains the declaration of the variable as Public, then set the value in the Close event of the second form. Be sure to open the second form in Dialog mode, so the first form will pause until the second form closes. Carl Rapson "Will G" <bigwillno2@yahoo.com> wrote in message news:4D808FC3-7CEE-4516-AFF3-1E8A72EFC6F9@microsoft.com... >I have a main form that contains a Search txtbox that when cmdSearch is > click, opens another form that contains a list box of items. what i want > to > do is sort this items by whatever letter is entered in the search txtbox > and > when clicking a selection from the list box, go to main form and fill in > the > areas with the selected item from the list box...can anyone help with this > issue? > -- > need help
![]() |
0 |
![]() |
Hey Carl, i tried this code below for filtering but it seems to give an error, can you spot what's wrong with it.... Private Sub List0_DblClick(Cancel As Integer) Dim stfrmName As String Dim stLinkCriteria As String stfrmName = "MSM" stLinkCriteria = "[ModelNumber]=" & Me![List0] DoCmd.OpenForm stfrmName , , , stLinkCriteria DoCmd.close acForm, Me.Name, acSaveYes End Sub this is suppose to be the trigger even that when clicking an item from that list box i should be able to populate the rest of the fields on the MSM form.....but it's giving me an error that says that OPENFORM action was canceled...what does that mean? -- need help "Will G" wrote: > Hey Carl, > i guess i am living on by ideas here man, it's there way for you to direct > me on how to do that, i am kinda new to this and i am just trying my best. > thanks > -- > need help > > > "Carl Rapson" wrote: > > > Each form can refer to the contents of a control on the other form. On your > > popup form, pull the contents from the Search textbox to sort your list. > > These newsgroups have lots of examples of referring to controls on other > > forms. > > > > For the second case, I would have the second form set a global > > (application-level) variable that the first form can then pick up > > immediately after the second form closes and use to locate the appropriate > > record. Create a module that contains the declaration of the variable as > > Public, then set the value in the Close event of the second form. Be sure to > > open the second form in Dialog mode, so the first form will pause until the > > second form closes. > > > > Carl Rapson > > > > "Will G" <bigwillno2@yahoo.com> wrote in message > > news:4D808FC3-7CEE-4516-AFF3-1E8A72EFC6F9@microsoft.com... > > >I have a main form that contains a Search txtbox that when cmdSearch is > > > click, opens another form that contains a list box of items. what i want > > > to > > > do is sort this items by whatever letter is entered in the search txtbox > > > and > > > when clicking a selection from the list box, go to main form and fill in > > > the > > > areas with the selected item from the list box...can anyone help with this > > > issue? > > > -- > > > need help > > > > > >
![]() |
0 |
![]() |
Hard to tell, but is the value in the listbox a string? If so, you need to put quotes around the value in stLinkCriteria: stLinkCriteria = "[ModelNumber]='" & Me![List0] & "'" Also, is [ModelNumber] included in your form's RecordSource? It will have to be in order to filter this way. Beyond that, I can't see anything. Carl Rapson "Will G" <bigwillno2@yahoo.com> wrote in message news:3B2E9715-9844-460B-A21C-272A9B8D1054@microsoft.com... > Hey Carl, > i tried this code below for filtering but it seems to give an error, can > you > spot what's wrong with it.... > > Private Sub List0_DblClick(Cancel As Integer) > > Dim stfrmName As String > Dim stLinkCriteria As String > stfrmName = "MSM" > stLinkCriteria = "[ModelNumber]=" & Me![List0] > DoCmd.OpenForm stfrmName , , , stLinkCriteria > DoCmd.close acForm, Me.Name, acSaveYes > End Sub > > this is suppose to be the trigger even that when clicking an item from > that > list box > i should be able to populate the rest of the fields on the MSM > form.....but > it's giving me an error that says that OPENFORM action was canceled...what > does that mean? > -- > need help > > > "Will G" wrote: > >> Hey Carl, >> i guess i am living on by ideas here man, it's there way for you to >> direct >> me on how to do that, i am kinda new to this and i am just trying my >> best. >> thanks >> -- >> need help >> >> >> "Carl Rapson" wrote: >> >> > Each form can refer to the contents of a control on the other form. On >> > your >> > popup form, pull the contents from the Search textbox to sort your >> > list. >> > These newsgroups have lots of examples of referring to controls on >> > other >> > forms. >> > >> > For the second case, I would have the second form set a global >> > (application-level) variable that the first form can then pick up >> > immediately after the second form closes and use to locate the >> > appropriate >> > record. Create a module that contains the declaration of the variable >> > as >> > Public, then set the value in the Close event of the second form. Be >> > sure to >> > open the second form in Dialog mode, so the first form will pause until >> > the >> > second form closes. >> > >> > Carl Rapson >> > >> > "Will G" <bigwillno2@yahoo.com> wrote in message >> > news:4D808FC3-7CEE-4516-AFF3-1E8A72EFC6F9@microsoft.com... >> > >I have a main form that contains a Search txtbox that when cmdSearch >> > >is >> > > click, opens another form that contains a list box of items. what i >> > > want >> > > to >> > > do is sort this items by whatever letter is entered in the search >> > > txtbox >> > > and >> > > when clicking a selection from the list box, go to main form and fill >> > > in >> > > the >> > > areas with the selected item from the list box...can anyone help with >> > > this >> > > issue? >> > > -- >> > > need help >> > >> > >> >
![]() |
0 |
![]() |
Hey Carl, thanks for your help, i guess it does work, only that, i got a little comfuse with what i am doing and i would love for you to clarify it for me.... i have the main form "MSM"...this form contains a search text field and i want to enter text here, a string, and when click the search button, i want to openup a different for that's named "frmSelectMSM" ...this form contains a list box with ModelNumber(string and could be for example A99000M), should be same field as the one entered in the search area txtbox.......this list box is the only item on this form....i want to filter this list if the user enters "A" or if the user enters the entire ModelNumber. And when i select one of this filtered ModelNumber, i like to populate the fields on the main form "MSM", that contains ModelNumber, and other fields. .....if you understand this, can you help me with it? -- need help "Carl Rapson" wrote: > Hard to tell, but is the value in the listbox a string? If so, you need to > put quotes around the value in stLinkCriteria: > > stLinkCriteria = "[ModelNumber]='" & Me![List0] & "'" > > Also, is [ModelNumber] included in your form's RecordSource? It will have to > be in order to filter this way. > > Beyond that, I can't see anything. > > Carl Rapson > > "Will G" <bigwillno2@yahoo.com> wrote in message > news:3B2E9715-9844-460B-A21C-272A9B8D1054@microsoft.com... > > Hey Carl, > > i tried this code below for filtering but it seems to give an error, can > > you > > spot what's wrong with it.... > > > > Private Sub List0_DblClick(Cancel As Integer) > > > > Dim stfrmName As String > > Dim stLinkCriteria As String > > stfrmName = "MSM" > > stLinkCriteria = "[ModelNumber]=" & Me![List0] > > DoCmd.OpenForm stfrmName , , , stLinkCriteria > > DoCmd.close acForm, Me.Name, acSaveYes > > End Sub > > > > this is suppose to be the trigger even that when clicking an item from > > that > > list box > > i should be able to populate the rest of the fields on the MSM > > form.....but > > it's giving me an error that says that OPENFORM action was canceled...what > > does that mean? > > -- > > need help > > > > > > "Will G" wrote: > > > >> Hey Carl, > >> i guess i am living on by ideas here man, it's there way for you to > >> direct > >> me on how to do that, i am kinda new to this and i am just trying my > >> best. > >> thanks > >> -- > >> need help > >> > >> > >> "Carl Rapson" wrote: > >> > >> > Each form can refer to the contents of a control on the other form. On > >> > your > >> > popup form, pull the contents from the Search textbox to sort your > >> > list. > >> > These newsgroups have lots of examples of referring to controls on > >> > other > >> > forms. > >> > > >> > For the second case, I would have the second form set a global > >> > (application-level) variable that the first form can then pick up > >> > immediately after the second form closes and use to locate the > >> > appropriate > >> > record. Create a module that contains the declaration of the variable > >> > as > >> > Public, then set the value in the Close event of the second form. Be > >> > sure to > >> > open the second form in Dialog mode, so the first form will pause until > >> > the > >> > second form closes. > >> > > >> > Carl Rapson > >> > > >> > "Will G" <bigwillno2@yahoo.com> wrote in message > >> > news:4D808FC3-7CEE-4516-AFF3-1E8A72EFC6F9@microsoft.com... > >> > >I have a main form that contains a Search txtbox that when cmdSearch > >> > >is > >> > > click, opens another form that contains a list box of items. what i > >> > > want > >> > > to > >> > > do is sort this items by whatever letter is entered in the search > >> > > txtbox > >> > > and > >> > > when clicking a selection from the list box, go to main form and fill > >> > > in > >> > > the > >> > > areas with the selected item from the list box...can anyone help with > >> > > this > >> > > issue? > >> > > -- > >> > > need help > >> > > >> > > >> > > > >
![]() |
0 |
![]() |
"Will G" <bigwillno2@yahoo.com> wrote in message news:E14F7B8A-5346-4357-B1EF-121F88C97901@microsoft.com... > Hey Carl, > thanks for your help, i guess it does work, only that, i got a little > comfuse with what i am doing and i would love for you to clarify it for > me.... > > i have the main form "MSM"...this form contains a search text field and i > want to enter text here, a string, and when click the search button, i > want > to openup a different for that's named "frmSelectMSM" ...this form > contains a > list box with ModelNumber(string and could be for example A99000M), should > be > same field as the one entered in the search area txtbox.......this list > box > is the only item on this form....i want to filter this list if the user > enters "A" or if the user enters the entire ModelNumber. And when i select > one of this filtered ModelNumber, i like to populate the fields on the > main > form "MSM", that contains ModelNumber, and other fields. .....if you > understand this, can you help me with it? > -- > need help > > <snipped> Let's try this again. There are two steps to this process: passing the value from your search text field to the second form so that the listbox can be filtered, and returning the listbox selection to the first form so it can be used to "populate the fields" (more on this later). For the first step, pass the value from the search text box to the second form in the OpenArgs parameter of the FormOpen method: DoCmd.OpenForm "frmSelectMSM",,,,,acDialog,txtSearchBox Be sure to use your own text box control name here. We open the second form in Dialog mode so that the first form "pauses" until the second form closes. In the Load event of the second form, "pick up" the value from the OpenArgs parameter and use it to filter your listbox. I can't really give an example here, because I don't know how you are populating the listbox with the model number strings. If the listbox is bound to a table, you can just modify the RowSource of the listbox to incorporate the value passed in OpenArgs: lstListBox.RowSource = "SELECT ... FROM ... WHERE [ModelNumber] LIKE '" & OpenArgs & "*'" I made up the name of the listbox control here, so be sure to use your actual control name. If you are populating the listbox by some other method, you'll need to adjust it as needed to incorporate the value in OpenArgs. For the second step (returning the listbox selection back to the first form), you need to first create a module to define an application-level ("global") variable that can be used from both forms. Create a new module (or you can use an existing module if you have one) and add the variable declaration: Public gblSelection As String In the second form, in the DblClick event of the listbox (or whatever other method you use to exit the form), store the listbox selection in the global variable: gblSelection = lstListBox (be sure to use your own variable and control names here). Back in the MSM form, immediately following the OpenForm call that opened the second form, pick up the value from the global variable and use it to "filter" the MSM form: Me.RecordSource = "SELECT ... FROM ... WHERE [ModelNumber]='" & gblSelection & "'" This assumes you're using an SQL statement for the form's RecordSource (which is what I prefer, for just this reason). If you're using a table or query, you may want to use the form's Filter and FilterOn properties instead (like in your previous question). If your MSM form is unbound, you can fetch the record from the table yourself (with a Recordset) and populate the controls on the form. I don't know if there's more I can add to this without actually writing the code for you. Study these examples, look in Access and VB Help, and search these newsgroups for specifics. What you're trying to do is fairly common and has been addressed many times in these newsgroups. Good luck, Carl Rapson
![]() |
0 |
![]() |
Hey Carl thanks for the help man, but i guess i am just gonna try something else because it's not working. the click event of the search fields it's opening the other form but that's all it's doing. and again it might not be something that i am not seeing since i have very little experience doing this. what did is this..... Main for: on clik DoCmd.OpenForm "frmSelectMSM", , , , , acDialog, TxtSearch Me.RecordSource = "SELECT [MSM].[ModelNumber] FROM [MSM] WHERE [ModelNumber]='" & gblSelection & "'" frmSelectMSM: Private Sub SearchListBox_DblClick(Cancel As Integer) gblSelection = SearchListBox End Sub Private Sub Form_Filter(Cancel As Integer, FilterType As Integer) SearchListBox.RowSource = "SELECT [MSM].[ModelNumber] FROM [MSM] WHERE [ModelNumber] LIKE '" & OpenArgs & "*'" End Sub GLOBALMODULE: Option Compare Database Public gblSelection As String frmSelectMSM: recordsource: tblMSM ListBox: no control source row source.....SELECT [MSM].[MSMID], [MSM].[ModelNumber] FROM [MSM]; -- need help "Carl Rapson" wrote: > "Will G" <bigwillno2@yahoo.com> wrote in message > news:E14F7B8A-5346-4357-B1EF-121F88C97901@microsoft.com... > > Hey Carl, > > thanks for your help, i guess it does work, only that, i got a little > > comfuse with what i am doing and i would love for you to clarify it for > > me.... > > > > i have the main form "MSM"...this form contains a search text field and i > > want to enter text here, a string, and when click the search button, i > > want > > to openup a different for that's named "frmSelectMSM" ...this form > > contains a > > list box with ModelNumber(string and could be for example A99000M), should > > be > > same field as the one entered in the search area txtbox.......this list > > box > > is the only item on this form....i want to filter this list if the user > > enters "A" or if the user enters the entire ModelNumber. And when i select > > one of this filtered ModelNumber, i like to populate the fields on the > > main > > form "MSM", that contains ModelNumber, and other fields. .....if you > > understand this, can you help me with it? > > -- > > need help > > > > > <snipped> > > Let's try this again. There are two steps to this process: passing the value > from your search text field to the second form so that the listbox can be > filtered, and returning the listbox selection to the first form so it can be > used to "populate the fields" (more on this later). > > For the first step, pass the value from the search text box to the second > form in the OpenArgs parameter of the FormOpen method: > > DoCmd.OpenForm "frmSelectMSM",,,,,acDialog,txtSearchBox > > Be sure to use your own text box control name here. We open the second form > in Dialog mode so that the first form "pauses" until the second form closes. > In the Load event of the second form, "pick up" the value from the OpenArgs > parameter and use it to filter your listbox. I can't really give an example > here, because I don't know how you are populating the listbox with the model > number strings. If the listbox is bound to a table, you can just modify the > RowSource of the listbox to incorporate the value passed in OpenArgs: > > lstListBox.RowSource = "SELECT ... FROM ... WHERE [ModelNumber] LIKE '" & > OpenArgs & "*'" > > I made up the name of the listbox control here, so be sure to use your > actual control name. If you are populating the listbox by some other method, > you'll need to adjust it as needed to incorporate the value in OpenArgs. > > For the second step (returning the listbox selection back to the first > form), you need to first create a module to define an application-level > ("global") variable that can be used from both forms. Create a new module > (or you can use an existing module if you have one) and add the variable > declaration: > > Public gblSelection As String > > In the second form, in the DblClick event of the listbox (or whatever other > method you use to exit the form), store the listbox selection in the global > variable: > > gblSelection = lstListBox > > (be sure to use your own variable and control names here). Back in the MSM > form, immediately following the OpenForm call that opened the second form, > pick up the value from the global variable and use it to "filter" the MSM > form: > > Me.RecordSource = "SELECT ... FROM ... WHERE [ModelNumber]='" & gblSelection > & "'" > > This assumes you're using an SQL statement for the form's RecordSource > (which is what I prefer, for just this reason). If you're using a table or > query, you may want to use the form's Filter and FilterOn properties instead > (like in your previous question). If your MSM form is unbound, you can fetch > the record from the table yourself (with a Recordset) and populate the > controls on the form. > > I don't know if there's more I can add to this without actually writing the > code for you. Study these examples, look in Access and VB Help, and search > these newsgroups for specifics. What you're trying to do is fairly common > and has been addressed many times in these newsgroups. > > Good luck, > > Carl Rapson > > >
![]() |
0 |
![]() |
In frmSelectMSM, you need to set SearchListBox.RowSource in the Form_Load event, not the Form_Filter event. Carl Rapson "Will G" <bigwillno2@yahoo.com> wrote in message news:76181599-EB00-4908-8C8E-658AC435D18A@microsoft.com... > Hey Carl thanks for the help man, but i guess i am just gonna try > something > else because it's not working. the click event of the search fields it's > opening the other form but that's all it's doing. and again it might not > be > something that i am not seeing since i have very little experience doing > this. what did is this..... > Main for: > on clik > DoCmd.OpenForm "frmSelectMSM", , , , , acDialog, TxtSearch > Me.RecordSource = "SELECT [MSM].[ModelNumber] FROM [MSM] WHERE > [ModelNumber]='" & gblSelection & "'" > > frmSelectMSM: > > Private Sub SearchListBox_DblClick(Cancel As Integer) > gblSelection = SearchListBox > End Sub > > Private Sub Form_Filter(Cancel As Integer, FilterType As Integer) > SearchListBox.RowSource = "SELECT [MSM].[ModelNumber] FROM [MSM] WHERE > [ModelNumber] LIKE '" & OpenArgs & "*'" > End Sub > > GLOBALMODULE: > Option Compare Database > Public gblSelection As String > > frmSelectMSM: > recordsource: tblMSM > > ListBox: > no control source > row source.....SELECT [MSM].[MSMID], [MSM].[ModelNumber] FROM [MSM]; > -- > need help > > > "Carl Rapson" wrote: > >> "Will G" <bigwillno2@yahoo.com> wrote in message >> news:E14F7B8A-5346-4357-B1EF-121F88C97901@microsoft.com... >> > Hey Carl, >> > thanks for your help, i guess it does work, only that, i got a little >> > comfuse with what i am doing and i would love for you to clarify it for >> > me.... >> > >> > i have the main form "MSM"...this form contains a search text field and >> > i >> > want to enter text here, a string, and when click the search button, i >> > want >> > to openup a different for that's named "frmSelectMSM" ...this form >> > contains a >> > list box with ModelNumber(string and could be for example A99000M), >> > should >> > be >> > same field as the one entered in the search area txtbox.......this list >> > box >> > is the only item on this form....i want to filter this list if the user >> > enters "A" or if the user enters the entire ModelNumber. And when i >> > select >> > one of this filtered ModelNumber, i like to populate the fields on the >> > main >> > form "MSM", that contains ModelNumber, and other fields. .....if you >> > understand this, can you help me with it? >> > -- >> > need help >> > >> > >> <snipped> >> >> Let's try this again. There are two steps to this process: passing the >> value >> from your search text field to the second form so that the listbox can be >> filtered, and returning the listbox selection to the first form so it can >> be >> used to "populate the fields" (more on this later). >> >> For the first step, pass the value from the search text box to the second >> form in the OpenArgs parameter of the FormOpen method: >> >> DoCmd.OpenForm "frmSelectMSM",,,,,acDialog,txtSearchBox >> >> Be sure to use your own text box control name here. We open the second >> form >> in Dialog mode so that the first form "pauses" until the second form >> closes. >> In the Load event of the second form, "pick up" the value from the >> OpenArgs >> parameter and use it to filter your listbox. I can't really give an >> example >> here, because I don't know how you are populating the listbox with the >> model >> number strings. If the listbox is bound to a table, you can just modify >> the >> RowSource of the listbox to incorporate the value passed in OpenArgs: >> >> lstListBox.RowSource = "SELECT ... FROM ... WHERE [ModelNumber] LIKE '" & >> OpenArgs & "*'" >> >> I made up the name of the listbox control here, so be sure to use your >> actual control name. If you are populating the listbox by some other >> method, >> you'll need to adjust it as needed to incorporate the value in OpenArgs. >> >> For the second step (returning the listbox selection back to the first >> form), you need to first create a module to define an application-level >> ("global") variable that can be used from both forms. Create a new module >> (or you can use an existing module if you have one) and add the variable >> declaration: >> >> Public gblSelection As String >> >> In the second form, in the DblClick event of the listbox (or whatever >> other >> method you use to exit the form), store the listbox selection in the >> global >> variable: >> >> gblSelection = lstListBox >> >> (be sure to use your own variable and control names here). Back in the >> MSM >> form, immediately following the OpenForm call that opened the second >> form, >> pick up the value from the global variable and use it to "filter" the MSM >> form: >> >> Me.RecordSource = "SELECT ... FROM ... WHERE [ModelNumber]='" & >> gblSelection >> & "'" >> >> This assumes you're using an SQL statement for the form's RecordSource >> (which is what I prefer, for just this reason). If you're using a table >> or >> query, you may want to use the form's Filter and FilterOn properties >> instead >> (like in your previous question). If your MSM form is unbound, you can >> fetch >> the record from the table yourself (with a Recordset) and populate the >> controls on the form. >> >> I don't know if there's more I can add to this without actually writing >> the >> code for you. Study these examples, look in Access and VB Help, and >> search >> these newsgroups for specifics. What you're trying to do is fairly common >> and has been addressed many times in these newsgroups. >> >> Good luck, >> >> Carl Rapson >> >> >>
![]() |
0 |
![]() |
Hey Carl again thanks for your help and for being patient with me....i did what you told me, got the searchListBox.Rowsource at the load even of the frmSelectMSM, but it doesnt work, all it does is open the form and this time, the list shows no record. i have it set up just as stated in the previous post and with the change that you just suggested and still dont load with ModelNumbers sorted. any further suggestion? -- need help "Carl Rapson" wrote: > In frmSelectMSM, you need to set SearchListBox.RowSource in the Form_Load > event, not the Form_Filter event. > > Carl Rapson > > "Will G" <bigwillno2@yahoo.com> wrote in message > news:76181599-EB00-4908-8C8E-658AC435D18A@microsoft.com... > > Hey Carl thanks for the help man, but i guess i am just gonna try > > something > > else because it's not working. the click event of the search fields it's > > opening the other form but that's all it's doing. and again it might not > > be > > something that i am not seeing since i have very little experience doing > > this. what did is this..... > > Main for: > > on clik > > DoCmd.OpenForm "frmSelectMSM", , , , , acDialog, TxtSearch > > Me.RecordSource = "SELECT [MSM].[ModelNumber] FROM [MSM] WHERE > > [ModelNumber]='" & gblSelection & "'" > > > > frmSelectMSM: > > > > Private Sub SearchListBox_DblClick(Cancel As Integer) > > gblSelection = SearchListBox > > End Sub > > > > Private Sub Form_Filter(Cancel As Integer, FilterType As Integer) > > SearchListBox.RowSource = "SELECT [MSM].[ModelNumber] FROM [MSM] WHERE > > [ModelNumber] LIKE '" & OpenArgs & "*'" > > End Sub > > > > GLOBALMODULE: > > Option Compare Database > > Public gblSelection As String > > > > frmSelectMSM: > > recordsource: tblMSM > > > > ListBox: > > no control source > > row source.....SELECT [MSM].[MSMID], [MSM].[ModelNumber] FROM [MSM]; > > -- > > need help > > > > > > "Carl Rapson" wrote: > > > >> "Will G" <bigwillno2@yahoo.com> wrote in message > >> news:E14F7B8A-5346-4357-B1EF-121F88C97901@microsoft.com... > >> > Hey Carl, > >> > thanks for your help, i guess it does work, only that, i got a little > >> > comfuse with what i am doing and i would love for you to clarify it for > >> > me.... > >> > > >> > i have the main form "MSM"...this form contains a search text field and > >> > i > >> > want to enter text here, a string, and when click the search button, i > >> > want > >> > to openup a different for that's named "frmSelectMSM" ...this form > >> > contains a > >> > list box with ModelNumber(string and could be for example A99000M), > >> > should > >> > be > >> > same field as the one entered in the search area txtbox.......this list > >> > box > >> > is the only item on this form....i want to filter this list if the user > >> > enters "A" or if the user enters the entire ModelNumber. And when i > >> > select > >> > one of this filtered ModelNumber, i like to populate the fields on the > >> > main > >> > form "MSM", that contains ModelNumber, and other fields. .....if you > >> > understand this, can you help me with it? > >> > -- > >> > need help > >> > > >> > > >> <snipped> > >> > >> Let's try this again. There are two steps to this process: passing the > >> value > >> from your search text field to the second form so that the listbox can be > >> filtered, and returning the listbox selection to the first form so it can > >> be > >> used to "populate the fields" (more on this later). > >> > >> For the first step, pass the value from the search text box to the second > >> form in the OpenArgs parameter of the FormOpen method: > >> > >> DoCmd.OpenForm "frmSelectMSM",,,,,acDialog,txtSearchBox > >> > >> Be sure to use your own text box control name here. We open the second > >> form > >> in Dialog mode so that the first form "pauses" until the second form > >> closes. > >> In the Load event of the second form, "pick up" the value from the > >> OpenArgs > >> parameter and use it to filter your listbox. I can't really give an > >> example > >> here, because I don't know how you are populating the listbox with the > >> model > >> number strings. If the listbox is bound to a table, you can just modify > >> the > >> RowSource of the listbox to incorporate the value passed in OpenArgs: > >> > >> lstListBox.RowSource = "SELECT ... FROM ... WHERE [ModelNumber] LIKE '" & > >> OpenArgs & "*'" > >> > >> I made up the name of the listbox control here, so be sure to use your > >> actual control name. If you are populating the listbox by some other > >> method, > >> you'll need to adjust it as needed to incorporate the value in OpenArgs. > >> > >> For the second step (returning the listbox selection back to the first > >> form), you need to first create a module to define an application-level > >> ("global") variable that can be used from both forms. Create a new module > >> (or you can use an existing module if you have one) and add the variable > >> declaration: > >> > >> Public gblSelection As String > >> > >> In the second form, in the DblClick event of the listbox (or whatever > >> other > >> method you use to exit the form), store the listbox selection in the > >> global > >> variable: > >> > >> gblSelection = lstListBox > >> > >> (be sure to use your own variable and control names here). Back in the > >> MSM > >> form, immediately following the OpenForm call that opened the second > >> form, > >> pick up the value from the global variable and use it to "filter" the MSM > >> form: > >> > >> Me.RecordSource = "SELECT ... FROM ... WHERE [ModelNumber]='" & > >> gblSelection > >> & "'" > >> > >> This assumes you're using an SQL statement for the form's RecordSource > >> (which is what I prefer, for just this reason). If you're using a table > >> or > >> query, you may want to use the form's Filter and FilterOn properties > >> instead > >> (like in your previous question). If your MSM form is unbound, you can > >> fetch > >> the record from the table yourself (with a Recordset) and populate the > >> controls on the form. > >> > >> I don't know if there's more I can add to this without actually writing > >> the > >> code for you. Study these examples, look in Access and VB Help, and > >> search > >> these newsgroups for specifics. What you're trying to do is fairly common > >> and has been addressed many times in these newsgroups. > >> > >> Good luck, > >> > >> Carl Rapson > >> > >> > >> > > >
![]() |
0 |
![]() |
Sorry, I'm fresh out of ideas. Based on what you've given me, I don't see anything else to try. Carl Rapson "Will G" <bigwillno2@yahoo.com> wrote in message news:3011DF17-06BD-43E5-89CF-CE31AC1E31C1@microsoft.com... > Hey Carl > again thanks for your help and for being patient with me....i did what you > told me, got the searchListBox.Rowsource at the load even of the > frmSelectMSM, but it doesnt work, all it does is open the form and this > time, > the list shows no record. i have it set up just as stated in the previous > post and with the change that you just suggested and still dont load with > ModelNumbers sorted. any further suggestion? > -- > need help > > > "Carl Rapson" wrote: > >> In frmSelectMSM, you need to set SearchListBox.RowSource in the Form_Load >> event, not the Form_Filter event. >> >> Carl Rapson >> >> "Will G" <bigwillno2@yahoo.com> wrote in message >> news:76181599-EB00-4908-8C8E-658AC435D18A@microsoft.com... >> > Hey Carl thanks for the help man, but i guess i am just gonna try >> > something >> > else because it's not working. the click event of the search fields >> > it's >> > opening the other form but that's all it's doing. and again it might >> > not >> > be >> > something that i am not seeing since i have very little experience >> > doing >> > this. what did is this..... >> > Main for: >> > on clik >> > DoCmd.OpenForm "frmSelectMSM", , , , , acDialog, TxtSearch >> > Me.RecordSource = "SELECT [MSM].[ModelNumber] FROM [MSM] WHERE >> > [ModelNumber]='" & gblSelection & "'" >> > >> > frmSelectMSM: >> > >> > Private Sub SearchListBox_DblClick(Cancel As Integer) >> > gblSelection = SearchListBox >> > End Sub >> > >> > Private Sub Form_Filter(Cancel As Integer, FilterType As Integer) >> > SearchListBox.RowSource = "SELECT [MSM].[ModelNumber] FROM [MSM] WHERE >> > [ModelNumber] LIKE '" & OpenArgs & "*'" >> > End Sub >> > >> > GLOBALMODULE: >> > Option Compare Database >> > Public gblSelection As String >> > >> > frmSelectMSM: >> > recordsource: tblMSM >> > >> > ListBox: >> > no control source >> > row source.....SELECT [MSM].[MSMID], [MSM].[ModelNumber] FROM [MSM]; >> > -- >> > need help >> > >> > <snipped>
![]() |
0 |
![]() |