Results 1 to 15 of 15
  1. #1
    Join Date
    Apr 2007
    Posts
    81

    Unanswered: Please I need change combobox to textbox for searching box.

    Hi

    Please I need change combobox to textbox for searching box.

    See attachment, Open TeacherStudentSubFrm.

    Thanks
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Isn't this the same as this question? See the attachment in this post - it will help you!
    George
    Home | Blog

  3. #3
    Join Date
    Apr 2007
    Posts
    81
    Hi georgev

    Yes you are right; that is very good example, but has more than 200 line code,
    I am still trainee, I need easier than this code.

    thanks

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I don't quite understand the question.

    If you're trying to only show the records in the form which match the combobox, set the query for the RecordSource for the TeacherStudentSubFrm with criteria for the UserID column (ie. =Forms!MainFrm!TeacherStudentSubFrm!Combo17) and in the AfterUpdate for Combo17 simply set the RecordSource for the form to a qryUsersF which has the criteria or qryUsersAll which doesn't have the criteria. Remove the other code in the AfterUpdate.

    If you need to show a column from the combobox, simply add an unbound text box and set the ControlSource = Forms!MainFrm!TeacherStudentSubFrm!Combo17.column( 1) or whatever column number you want to show in that text box from the combobox.

    (see example in the attachment below for how to do both of the above) - use this as an example only for a little different way verses what georgev posted. His Search.zip is a very nice way to do a more in-depth search and I'd keep his sample on-hand to learn from and utilize as you get more advanced in your skillset.
    Attached Files Attached Files
    Last edited by pkstormy; 07-15-07 at 03:22.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by SAMI2
    Hi georgev

    Yes you are right; that is very good example, but has more than 200 line code,
    I am still trainee, I need easier than this code.

    thanks
    Which parts of the code don't you follow?
    There's some reasonable notations throughout the code and most of it you wont need. You only need the stuff behind the on click event of the button!

    Basically you want to grab the text from the textbox
    Code:
    Dim x As String
    x = Me.MyTextBox.Value
    Then you want to dynamically change the row source of the list box control
    Code:
    Dim SQL As String
    SQL = "SELECT Field1, Field2, Field3 FROM MyTable WHERE Field1 ='" & x & "'"
    My.MyListBox.RowSource = SQL
    Then finally a refresh to show the results.
    Code:
    Me.Refresh
    Simple, no?
    George
    Home | Blog

  6. #6
    Join Date
    Apr 2007
    Posts
    81
    Hi
    just I need delete comboBox and create textbox for attach in thread #1

    I make it but other problem coming.
    The other problem:
    When add new record for teacher by double click on the teacher record then add new, open again to show information, the student form open with the same information which I added for teacher.

    I make this attach just to show what I need in search box.

    THANKS
    Attached Files Attached Files

  7. #7
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    SAMI2 (Please read this ENTIRE post and download the example!),

    You have 2 good examples and different ways on your problem specified. Have you looked at BOTH examples (including the one I uploaded in the post above?)
    The Search.zip is a good example of how to do an in-depth search. If you've found Georgev's example too difficult to work with, I uploaded a "TwoQueryOpenDetailFormNEW.zip" file for another approach specific to your problem. Please take a look at the example I uploaded as well!! (it only has 4 lines of code and 2 queries - I used your database to show the example.)

    If you are opening a new form (frmTeacherDetail) to add a new record for the teacher (and your MainFrm/TeacherStudentSubFrm is open behnd the scenes), then after you add a new record in your frmTeacherDetail form, you "may" need to send a requery command back to the MainFrm/TeacherStudentSubFrm (ie. in the OnClose event of the frmTeacherDetail put in code: Forms!MainFrm!TeacherStudentSubFrm.requery). There is not always a need to do this though.

    ************************************************** ************
    But I can see in the example you've just uploaded that you have NOT looked at the sample I uploaded in my post. PLEASE look at this example as well!! When you are done looking at it, I'll answer any questions you may have on it. But if you don't look at it, it's difficult for me to help you.
    ************************************************** ************

    Here is the example again!! - It does EXACTLY what you want it to do:
    Attached Files Attached Files
    Last edited by pkstormy; 07-15-07 at 18:13.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  8. #8
    Join Date
    Apr 2007
    Posts
    81
    georgev, I try used this codes:
    -----
    Dim x As String
    x = Me.MyTextBox.Value
    Dim SQL As String
    SQL = "SELECT Field1, Field2, Field3 FROM MyTable WHERE Field1 ='" & x & "'"
    My.MyListBox.RowSource = SQL
    Me.Refresh
    -----
    pkstormy, and try this code:
    -----
    Private Sub Command17_Click()
    On Error GoTo Err_Command17_Click
    DoCmd.Close
    Forms!MainFrm!TeacherStudentSubFrm.Requery <<---your code
    Exit_Command17_Click:
    Exit Sub
    Err_Command17_Click:
    MsgBox Err.Description
    Resume Exit_Command17_Click
    End Sub
    -----
    In up codes the problems, when I add new record for teacher, and open again, the student form appear with teacher information.

    pkstormy, the first looking to sample because I hope to see solving.but the same problem with adding.

    in this post attach there no problem on the adding but need only create search box for TeacherStudentSubFrm same the search box in the thread #6

    thanks
    Attached Files Attached Files

  9. #9
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Whew SamI2, did you read my post with the attachment? The answer is in the post and in the attachment. The attachment does exactly what you want it to do including updating records. But maybe you're not closing the Details form for the next record and that's the problem.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  10. #10
    Join Date
    Apr 2007
    Posts
    81
    Hi pkstormy

    I add two records in your samples post #4 and #7.
    Sample post #4, I add two record in frmTeacherDetail by first name:
    TEACHER8
    TEACHER9
    Sample post #7, I add two record in frmTeacherDetail by first name:
    TEACHER08
    TEACHER09
    I upload both samples, try open MainFrm then double click on the new record first name, you will see frmStudentDetail is open with teacher information.

    In the thread #6, the sample no problem with the adding but need search box.

    Thanks
    Attached Files Attached Files

  11. #11
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Uh....this is because the TEACHER checkbox is marked as FALSE! for these records! The code is doing exactly what it's supposed to which is open frmStudentDetail if Teacher = false else open frmTeacherDetail. (both examples have the same code by the way.) On your MainFrm!TeacherStudentSubFrm you have no way to mark the Teacher field as true when you add a new record! You need to add this field to that form. Otherwise, no matter what code you use, Teacher is always false when you add a new record.
    Last edited by pkstormy; 07-17-07 at 12:37.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  12. #12
    Join Date
    Apr 2007
    Posts
    81
    Hi pkstormy

    I am very sory a bout that,
    but I do not want combo box I need textbox for search. if you can solve it please I need your help.

    in this post 8 attach there no problem on the adding but need only create search box for TeacherStudentSubFrm same the search box in the thread #6

    thanks

  13. #13
    Join Date
    Apr 2007
    Posts
    81
    HI pkstormy

    THANK YOU SO MUCH
    I appreciate your efforts, That is excellent solution


    http://www.dbforums.com/showthread.p...=1#post6285080

  14. #14
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Excellent! Than this thread is superfluous, closing.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  15. #15
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Thank you also SAMI2. Please come back for more help if you need it.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •