I need help here...
I have created a list box (LstCName) from a form named (contactlist) that picks up employee names from a query named (lkpcontacts). The employee names are displayed fine but when i click on a name, i want it to take me to that persons details which are stored in (frmcontacts). At the moment it's not doing it... can you help.
Private Sub LstCName_DblClick(Cancel As Integer)
' Double-clicking a name is the same as choosing the name
' and then clicking the edit button.
cmdSome_Click
End Sub
Private Sub cmdSome_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!LstCName.ItemsSelected.Count = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me!LstCName.ItemsSelected
' Grab the ContactID column for each selected item
strWhere = strWhere & Me!LstCName.Column(0, varItem) & ","
Next varItem
' Throw away the extra comma on the "IN" string
strWhere = Left$(strWhere, Len(strWhere) - 1)
' Open the contacts form filtered on the selected contacts
strWhere = "[ContactID] IN (" & strWhere & ") "
DoCmd.OpenForm FormName:="frmContacts", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
End Sub
7 1686
I need help here...
I have created a list box (LstCName) from a form named (contactlist) that picks up employee names from a query named (lkpcontacts). The employee names are displayed fine but when i click on a name, i want it to take me to that persons details which are stored in (frmcontacts). At the moment it's not doing it... can you help.
Private Sub LstCName_DblClick(Cancel As Integer)
' Double-clicking a name is the same as choosing the name
' and then clicking the edit button.
cmdSome_Click
End Sub
Private Sub cmdSome_Click()
Dim strWhere As String, varItem As Variant
' Request to edit items selected in the list box
' If no items selected, then nothing to do
If Me!LstCName.ItemsSelected.Count = 0 Then Exit Sub
' Loop through the items selected collection
For Each varItem In Me!LstCName.ItemsSelected
' Grab the ContactID column for each selected item
strWhere = strWhere & Me!LstCName.Column(0, varItem) & ","
Next varItem
' Throw away the extra comma on the "IN" string
strWhere = Left$(strWhere, Len(strWhere) - 1)
' Open the contacts form filtered on the selected contacts
strWhere = "[ContactID] IN (" & strWhere & ") "
DoCmd.OpenForm FormName:="frmContacts", WhereCondition:=strWhere
DoCmd.Close acForm, Me.Name
End Sub
Doesn't Me refer to the current object executed?
If so you'd be opening and closing the form almost instantaneously?
What happens if you step through the code?
NeoPa 32,556
Expert Mod 16PB
You're missing the quotes around the items in the IN() list in the WHERE clause.
The particular line should read :- - strWhere = strWhere & "'" & Me!LstCName.Column(0, varItem) & "',"
NeoPa 32,556
Expert Mod 16PB
Doesn't Me refer to the current object executed?
No, Me refers to the object in which the code has scope.
In this case, the owning form, or the form which is the parent of the object that this code is related to (LstCName).
Appreciate your help.... from what you've given me it now opens the form fine.....but no data within. Any ideas ?
NeoPa 32,556
Expert Mod 16PB
Appreciate your help.... from what you've given me it now opens the form fine.....but no data within. Any ideas ?
Can't help without any idea of what data is being processed; what is in the list box etc.
i'll keep it simple for now...
ContactID
FirstName
LastName
I need help here...
I have created a list box (LstCName) from a form named (contactlist) that picks up employee names from a query named (lkpcontacts). The employee names are displayed fine but when i click on a name, i want it to take me to that persons details which are stored in (frmcontacts). At the moment it's not doing it... can you help.
Try this: -
-
Private Sub LstCName_DblClick(Cancel As Integer)
-
' Double-clicking a name is the same as choosing the name
-
' and then clicking the edit button.
-
-
cmdSome_Click
-
-
End Sub
-
-
Private Sub cmdSome_Click()
-
Dim strWhere As String
-
Dim varItem As Variant
-
-
strWhere = "" ' initialise the variable
-
' Request to edit items selected in the list box
-
' If no items selected, then nothing to do
-
If Me!LstCName.ItemsSelected.Count = 0 Then Exit Sub
-
-
' Loop through the items selected collection
-
For Each varItem In Me!LstCName.ItemsSelected
-
' Grab the ContactID column for each selected item
-
'assuming ContactID is a number and not a string and ContactID is the bound column
-
strWhere = strWhere & "[ContactID]=" & Me!LstCName.ItemData(varItem) & " OR "
-
Next varItem
-
-
' Throw away the " OR " in the string
-
strWhere = Left(strWhere, Len(strWhere) - 4)
-
-
' Open the contacts form filtered on the selected contacts
-
-
DoCmd.OpenForm "frmContacts", , , strWhere
-
DoCmd.Close acForm, Me.Name
-
-
End Sub
-
-
Just a note...
Has the form "frmContacts" already got a where statement in its record source ?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Arijit Chatterjee |
last post by:
Hi Everybody,
I am facing another probs. I have created a trigger for table Tab1 for
perticular column col1 for checking value ranges.But at time for using
insert statement it is working fine but...
|
by: massimo |
last post by:
Hey,
I wrote this program which should take the numbers entered and sort them
out. It doesnąt matter what order, if decreasing or increasing.
I guess I'm confused in the sorting part. Anyone...
|
by: Kent |
last post by:
Hi!
I want to store data (of enemys in a game) as a linked list, each node will
look something like the following:
struct node
{
double x,y; // x and y position coordinates
struct enemy...
|
by: Robin Cole |
last post by:
I'd like a code review if anyone has the time. The code implements a basic
skip list library for generic use. I use the following header for debug
macros:
/*
public.h - Public declarations and...
|
by: JS |
last post by:
I have a file called test.c. There I create a pointer to a pcb struct:
struct pcb {
void *(*start_routine) (void *);
void *arg;
jmp_buf state;
int stack;
};
...
|
by: andrewcw |
last post by:
Seems it should be simple. I had problems with a larger
class and the newsgroup suggested something I also tried.
So I pruned my class to see if I could find out what could
be wrong, Still dont...
|
by: polecat |
last post by:
Im new to .NET and I am having probs with this
Every time I reload the form the same data is repeated again....
Done reading on msdn and another forum
cant figure out why the...
|
by: bkpatel |
last post by:
get Join the PHP community and share ur probs - soln
<table border=0 style="background-color: #fff; padding: 5px;"
cellspacing=0>
<tr><td>
<img...
|
by: brettokumar |
last post by:
hai
im storing value in cookies. if my 2nd value or 3rd value is stored means my previous cookies are expired my current cookies only stored others cookies values will be null
how to i solve...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
| |