Connecting Tech Pros Worldwide Forums | Help | Site Map

Access 2003 - forms and radio buttons

Newbie
 
Join Date: Oct 2009
Posts: 5
#1: Oct 6 '09
Hey all,

i am trying to do the following and am having problems, if there is anyway you can guide me or even point me to some material that may help it would be great.

I have created a form in access that allows users to input data and save record, the form is used for logging system faults when users call in.

when a uiser calls the operator will answer call and place the username in field1 (combo box) this autopopulates all the other text boxes.

the underlying data is a users table which has username and whether the user is active or inactive.

what i need help in is -


1) i have 2 fields field1 and field2, when i start to input a username into field1 i want field2 to show all usernames that have the same wording/text in their username untill a point i select one. (both fields will reference the same users table)

2) on my users table their are 2 types of users 1) active and 2) Inactive i have 3 radio buttons that i want users to select to say whether they want to search the 1) active users or 2) inactive users or 3) All users for the username they are about to enter in field1

Any support would be much appreciated

Look forward to hearing from you.
Expert
 
Join Date: Jul 2008
Location: Maryland
Posts: 1,164
#2: Oct 6 '09

re: Access 2003 - forms and radio buttons


It's hard to match the ease with which the combo box autocomplete works. If you want to be able to search in the middle of the field though, I'm assuming field2 is a list box or something. You would use the Change() event of field1 (text box) to change the source of field2 based on the current value in field1 every time a letter changed.
I would use a select case statement to form the criteria of the SQL based on the radio button selected. This should give you some idea what I mean, but it's not tested code.
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtField1_Change()
  2.  
  3.   strSQL = "Select * FROM Users WHERE " _
  4.    & "UserName LIKE ""*" & txtField1.Text & "*"""
  5.  
  6.   Select Case radioGroup
  7.     Case 1
  8.       strSQL = strSQL & " And Status = ""Active"""
  9.     Case 2
  10.       strSQL = strSQL & " And Status = ""Inactive"""
  11.     Case 3
  12.       'strSQL = strSQL & ""
  13.     Case Default
  14.       MsgBox "You messed something up!"
  15.   End Select
  16.  
  17.   lstField2.RowSource = strSQL
Newbie
 
Join Date: Oct 2009
Posts: 5
#3: Oct 7 '09

re: Access 2003 - forms and radio buttons


Hey ChipR,

Tried following your outline above and i keep getting case default, not sure if its me or the code!

If it helps i can list out the names of each object (not sure if it will)

Combobox to insert username in = cbonames
Radio button for active users = Active
radio button for Inactive users = Inactive
Radio button for all users = All

on my users table the column for status is called "status" and the values are "active or Inactive"

when i apply a similar code to what you have provided the case default keeps coming up and each time box change error message appears. (due to sub being on change)

Sorry to annoy you.
Expert
 
Join Date: Jul 2008
Location: Maryland
Posts: 1,164
#4: Oct 7 '09

re: Access 2003 - forms and radio buttons


You'll want to look at the radio buttons' properties and check the Option Value. This is what you'll compare to in your Select Case.
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,714
#5: Oct 8 '09

re: Access 2003 - forms and radio buttons


Thread hijack moved to Radio Button Problem.
Reply

Tags
access, auto, forms, vba