473,394 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

ListBox Row Click Event

Hi all

Is there any event for list box row click/double click.I want to open a new form based on the row selected and when it is clicked.I know there's one for the whole list box but i am looking for a row click event.I want to know if there is such an event or any other way to implement this.


thanks
Sree
Jan 20 '09 #1
10 6749
DonRayner
489 Expert 256MB
Hi Sree, How about using the after update event to trigger opening the form.
Jan 20 '09 #2
Megalog
378 Expert 256MB
There is no row specific event. Basically you need to code whatever routine you need, to look at the selected row(s) and perform whatever function it is you're trying to do. Check out the help file on the listbox's 'Selected', 'ListCount', and 'Column' properties. Using those you should be able to come up with a nice loop that runs through your listbox's rows and performs whatever function you need on the selected row's data.

If you need anything more specific, then please post whatever it is you're specifically trying to do, with example data. I know you said you're trying to open forms, but based on what?

-Mega
Jan 20 '09 #3
don

thanks for the help.i'll try that.

Megalog

i am populating employee info in the list box and each record refers to one employee.What i am trying to do is open the selected employee details page/form when i click on the particular record/row.I have Employee Last Name ,First Name ,UserName(primarykey),Email in the listbox.I want the specific form to be opened on some double click event rather than a single click.

hope this helps
Sree
Jan 20 '09 #4
Megalog
378 Expert 256MB
"UserName" is the primary key for the employee table? This isnt a text value is it? You do have a normal numeric unique PK in that table as well, I hope? I've seen where people use the full name in the contacts/employee table as the PK, and it can get ugly once you get two employees named John Smith, etc.

Also, what is the name of the form you want opened?
Jan 20 '09 #5
Megalog

Yes UserName is the primary key.Its the same as the email id without the domain name so its always unique(something like for outlook exchange).

thanks
Sree
Jan 20 '09 #6
Megalog
378 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. Dim varRow
  2. Dim varID
  3. varRow = Me.List0.ListIndex + 1
  4. varID = Me.List0.Column(2, varRow)
  5.  
  6. 'Use this if UserName is a numeric value
  7. DoCmd.OpenForm "Contact Details", , , "[UserName]=" & varID
  8.  
  9. 'Use this if UserName is a text value
  10. DoCmd.OpenForm "Contact Details", , , "[UserName]='" & varID & "'"
Replace "List0" with your listbox name. From what you said before, I'm assuming UserName is the 3rd column in your listbox. If it isnt (if you have hidden values, etc) then adjust the VarID above so that the number is whichever column it's in, minus 1. (first column starts at zero).

You didnt state what the name of the form you're opening was, so replace my "Contact Details" with the formal form name.. and you should be set. Also, Comment out or delete whichever DoCmd.OpenForm line doesnt apply (depending on whether UserName is numeric or text).
Place all that code in the doubleclick event on the listbox and give it a shot.


-Mega
Jan 20 '09 #7
I laid out a basic prototype and it seems to work on the double click event but i still have to do some more background work to populate the form details which i can do.

thanks for your help
Sree
Jan 20 '09 #8
Megalog

I tried to use the command

DoCmd.OpenForm "Individual_Info", , , "[UserName]='" & rs!UserName & "'"

and i get this error on double click

"run time error 2491 :the action or method is invalid because form is not bound to table/query"

any idea what i am doing wrong??

thanks
Sree
Jan 21 '09 #9
Megalog
378 Expert 256MB
Well it seems the error message is going to ask the same thing I'm going to ask... is the form bound to a table or query? Go to it's recordsource property and see if a table/query name, or a select statement is there. And if there is, make sure 'Username' is a valid field within that source.

If you open the form manually, are you able to cycle through all the existing user records? If so, then it's bound to that data.

If not, then what exactly is the intended function of this form? I assumed it was bound to a user table, that you wanted to pop open to see all the user's full details from a list box. The better you explain things, the better I can help. =)
Jan 21 '09 #10
onyris
42
oiuokloooooooooooooooooooooooooooo
May 19 '09 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: CoreyMas | last post by:
Hello everyone Is there a way to create a double click event on a listbox control in VB.net without having to resort to Javascript? Thanks in advance Corey
1
by: Daniel G | last post by:
Hello , In an ASP.Net page, there are some DropDownLists used for adding some conditions to a Select statement, a button (server-side, too). And in the same page there is a ListBox that must...
5
by: PAPutzback | last post by:
Form2 has one purpose to open and list some names and ids. I want to handle the list box click event on form2 so I can get the selected value onto a field in form1. I changed this Dim MyForm2...
1
by: tony | last post by:
Hello! If you drag a ListBox into a windowform and then right click on this ListBox and then chose property. When you have the properties up click on the flash symbol for seeing all the events...
1
by: superjacent | last post by:
Hope someone can point me in the right direction. When opening a form the 'click' event of the ListBox is invoked (run). I thought the 'click' event of the ListBox is only invoked when clicking...
4
by: Jeff User | last post by:
Hi Using .NET 1.1, C#, web app I (actually our client) would like to be able to double click a selection in a listbox and have it postback to server . There I would want to access the item that...
5
by: buddydasari | last post by:
Hi all I wrote a listbox onclick event.On a click i want to get the selected row details but the listbox.selected(i) always returns false ,it returns true only in double click event.Are they...
7
by: onyris | last post by:
Hi guys, have a form which displays all the records i have in my database , and a search box for the user to search for a specific one . On the search button, i run a macro which opens another...
2
by: svibuk | last post by:
i have a asp.net list box populated with databae data , autopostback = true wht i need is 1) when double clicked(double click event) i want it to be visible=false 2)i want to move between the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.