Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 Access Forms/Queries
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Dave.
Senior Member

USA
1037 Posts

Posted - 04 June 2004 :  16:54:41  Show Profile
Hey everyone.

I'm pretty experienced in VB6, but I need to make this application with Access (Access 2003). I really don't know too much yet, but here is what I'm trying to do:

I have form, on it is a text box, a command button and a combo box. (And a bunch of other labels that I have to output the data).

I want to enter someones last name in the first text box, press the command button and have the combo box populated with all the people that have that last name. I then want to click a name from that combo box and have it display all the information for that person.

I can't really find anything on how to do this, and I don't know how to setup the query to do this.

*sigh*, in VB I could just CreateObject the ADO stuff and be done in 5mins. ;(

OneWayMule
Dev. Team Member & Support Moderator

Austria
4969 Posts

Posted - 04 June 2004 :  18:35:59  Show Profile  Visit OneWayMule's Homepage  Send OneWayMule an ICQ Message
I'd do it the following way.

Let's say we got a table MEMBERS with the fields ID, M_NAME, M_LASTNAME.
Now we've got the form with the following objects (as you listed above):

name1 - text field for the name
ok - the button
name2 - combo box for the last name
m_id - a text field for the id

All you have to do now is to add a procedure to the properties of ok onclick) and one to name2 (onchange) [not sure if you understand what I mean, but I'm working with a German version of Access and have no idea how exactly that stuff is called in your english Access] and add the following code to the form:

Option Compare Database

Private Sub Form_Load()
    name1.Value = ""
    name2.Value = ""
    m_id.Value = ""
    name2.Enabled = False
End Sub

Private Sub name2_Change()
    Dim db As DAO.database, rs As DAO.Recordset
    Set db = CurrentDb
    Set rs = db.OpenRecordset("SELECT TOP 1 ID FROM MEMBERS WHERE M_LASTNAME='" & name2.Value & "'")
    If Not rs.EOF And Not rs.BOF Then m_id.Value = rs![id]
    rs.close
End Sub

Private Sub ok_Click()
    name2.Enabled = True
    name2.RowSource = "SELECT [M_LASTNAME] FROM [MEMBERS] WHERE M_NAME='" & name1.Value & "'"
End Sub


If you're not sure what I mean, feel free to ask. I can also provide the sample database I used for this if you would like. Hope that helps.

My MODs:
Birthdays - Custom Policy - F.A.Q. Administration - Forum Rules - Guestbook
Links Manager - MyOwnGoogle - Profile Views - Search Log - WebSearch

Useful stuff:
Forum and MOD Installation - MOD Installation Guide - Snitz v3.4.05 Readme - Free ASP Hosts - Support Snitz
Go to Top of Page

Dave.
Senior Member

USA
1037 Posts

Posted - 04 June 2004 :  19:31:53  Show Profile
Ahh, that got me going, now to figure out how to do columns in a combobox. :/

Thanks OWM, you saved me a lot of time.
Go to Top of Page

OneWayMule
Dev. Team Member & Support Moderator

Austria
4969 Posts

Posted - 04 June 2004 :  19:32:39  Show Profile  Visit OneWayMule's Homepage  Send OneWayMule an ICQ Message
No problem, glad I could help.

My MODs:
Birthdays - Custom Policy - F.A.Q. Administration - Forum Rules - Guestbook
Links Manager - MyOwnGoogle - Profile Views - Search Log - WebSearch

Useful stuff:
Forum and MOD Installation - MOD Installation Guide - Snitz v3.4.05 Readme - Free ASP Hosts - Support Snitz
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07