By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,486 Members | 2,034 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,486 IT Pros & Developers. It's quick & easy.

HOW TO

P: n/a
DK
Hello everybody,

I hope somebody will help me.

I have form1 with CompanyID, ContactName,Department,Phone on it.
Id like to open Form2 with all contacts in Company selected in Form1.
On Form2, I have listbox with source
SELECT From Contacts ContactName,department,phoneNumber where CompanyID=
me.openarg
(This part going fine)
Id like user to pick up one of contacts from the list, close form2 and
fill-up fields in Form1 with details from Form2.

Id like to call this procedure from several forms ( Form1, FormX,....)

Thank You in advance

DK
Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
pass the Company ID in the where clause.

[CompanyID]=Forms![OpenFormName]![CompanyID]

Nov 13 '05 #2

P: n/a
DK
Thanks, but point is that I need to return value of ListBox from Form2 into
Form from which form 2 was oppened.

Thanks
DK
<pi********@hotmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
pass the Company ID in the where clause.

[CompanyID]=Forms![OpenFormName]![CompanyID]

Nov 13 '05 #3

P: n/a
rkc
DK wrote:
Thanks, but point is that I need to return value of ListBox from Form2 into
Form from which form 2 was oppened.


So pass three pieces of information in openargs instead of one.

"companyid;form2;controlOnform2"

dim v as variant
v = split(me.openargs,";")

"SELECT From Contacts.... where CompanyID=" & v(0)

Forms(v(1)).Controls(v(2)) = valueOflistbox
Nov 13 '05 #4

P: n/a
DK
Thanks RKC !
first part of code going fine. Splitting of openarg is OK, and I manage to
control data in ListBox on form2.
Are You able to help me with whole story ?

I have form ContactAction1 and ContactAction2
Fields are: CompanyID,ContactPerson,ContactPhone
After User input CompanyID it is able to open form "ReachPerson"
Private Sub Command201_Click()
On Error GoTo Err_Command201_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ReachPerson"
rem Text1Name and Text2Name are controls with Contact Person Name
and ContactPhone
DoCmd.OpenForm stDocName, acNormal, , , acFormPropertySettings,
acWindowNormal, Me.CompanyID & ";"& Screen.ActiveForm & ";" & Text1Name &
";" & Text2Name

Exit_Command201_Click:
Exit Sub

Err_Command201_Click:
MsgBox Err.Description
Resume Exit_Command201_Click

End Sub

After user oppened form "ReachPerson" he selecting person from List0 (
List0 is filled exactly as it should be- EXCELLENT !)

Private Sub Accept_Click()
On Error GoTo Err_Accept_Click

Rem HERE IS PROBLEM !

Forms(v(1)).Controls(v(2)) = Me.List0
Forms(v(1)).Controls(v(3)) = Me.List0.Column(1)

DoCmd.Close acForm, "ReachPerson"

Exit_Accept_Click:
Exit Sub

Err_Accept_Click:
MsgBox Err.Description
Resume Exit_Accept_Click

End Sub
Thank You in advance,

DK
"rkc" <rk*@rochester.yabba.dabba.do.rr.bomb> wrote in message
news:Av*******************@twister.nyroc.rr.com...
DK wrote:
Thanks, but point is that I need to return value of ListBox from Form2 into Form from which form 2 was oppened.


So pass three pieces of information in openargs instead of one.

"companyid;form2;controlOnform2"

dim v as variant
v = split(me.openargs,";")

"SELECT From Contacts.... where CompanyID=" & v(0)

Forms(v(1)).Controls(v(2)) = valueOflistbox

Nov 13 '05 #5

P: n/a
rkc
DK wrote:
Thanks RKC !
first part of code going fine. Splitting of openarg is OK, and I manage to
control data in ListBox on form2.
Are You able to help me with whole story ?

I have form ContactAction1 and ContactAction2
Fields are: CompanyID,ContactPerson,ContactPhone
After User input CompanyID it is able to open form "ReachPerson"
Private Sub Command201_Click()
On Error GoTo Err_Command201_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ReachPerson"
rem Text1Name and Text2Name are controls with Contact Person Name
and ContactPhone
DoCmd.OpenForm stDocName, acNormal, , , acFormPropertySettings,
acWindowNormal, Me.CompanyID & ";"& Screen.ActiveForm & ";" & Text1Name &
";" & Text2Name

Exit_Command201_Click:
Exit Sub

Err_Command201_Click:
MsgBox Err.Description
Resume Exit_Command201_Click

End Sub

After user oppened form "ReachPerson" he selecting person from List0 (
List0 is filled exactly as it should be- EXCELLENT !)

Private Sub Accept_Click()
On Error GoTo Err_Accept_Click

Rem HERE IS PROBLEM !

Forms(v(1)).Controls(v(2)) = Me.List0
Forms(v(1)).Controls(v(3)) = Me.List0.Column(1)

DoCmd.Close acForm, "ReachPerson"

Exit_Accept_Click:
Exit Sub

Err_Accept_Click:
MsgBox Err.Description
Resume Exit_Accept_Click

End Sub


You do not show where and how you are declaring the variant to hold the
openargs array. The easiest way is to declare it as a module level
variable so it can be used by any method in the form's code module.
Populate it in the form's Load event.

'declare module level variable
Private v As Variant

Private Sub Form_Load()
Dim i As Integer
v = Split(Me.OpenArgs, ";")

'debug loop so you can verify the contents of the array
'in the immediate window
For i = 0 To UBound(v)
Debug.Print v(i)
Next
'end debug loop
End Sub
Screen.ActiveForm should be Screen.ActiveForm.Name so there is no
confusion as to whether you are refering to an object or a string.


Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.