Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing value to other form

Status
Not open for further replies.

kkgusta

MIS
Nov 10, 2005
42
NZ
Hi,
I am trying to pass the values from a user form(datasheetview) to fill up the related textbox in the search form where people can get the user details and generate a customize report. For example when user double click on a particular row of data on the user datasheet view form, the firstname of the particular user will pass to the firstnaem textbox on the search form.

this is the code I use:

Private Sub Form_DblClick(Cancel As Integer)
On Error GoTo from_DblClick_Err

Dim strFirstname As String
Dim strLastname As String
Dim strID As Integer
Dim str As String

Me.FirstName.SetFocus
strFirstname = Me.FirstName.Text
Me.LastName.SetFocus
strLastname = Me.LastName.Text
Me.OwnerID.SetFocus
strID = Me.OwnerID.Text

Form![search form].cboFirstName.Text = strFirstname
* I have tried this code but it keep on saying that office can't find the field that i referred. The problem i i been checking this code for many time and there is nothing wrong with the spelling.

Exit Sub

from_DblClick_Err:
MsgBox Err.Description

End Sub



Hope you guys can help me
Thank
 
Hi
I think you need to change the code from the form double click to the double click of the textboxes, which would also allow you to change the details of the search accordingly.

There is a missing 's' here:
Forms![search form].cboFirstName.Text = strFirstname
 
kkgusta,
Here is the problem. When you add a field to a recordset or a form or report you can reference the field as follows. (Assuming your control and field do not have the same name)

Me.fieldName
or
Me!fieldName
Fields only have one property and that is "value". So
Me.fieldName.value
or
Me!fieldName.value
Will work, but not
Me.fieldName.text.
Since a field does not have a text property

To reference the control
Me.controlName
Me.controls("controlName")
Me.controls!controlName
Me!controlName
Then you can follow these with a text property.

However it sounds like you have a bound form. If that is the case.
strFirstname = Me.FirstName (where FirstName is a FieldName)
strLastname = Me.LastName (LN is a FieldName)
strID = Me.OwnerID (where OwnerID is a FN
 
Thank for all your help. I have fixed the problem now. Majp, your explanation is very helpful thank a lot
Cheers,


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top