Can't show control on form

  • Thread starter Thread starter Tony Williams
  • Start date Start date
T

Tony Williams

I have a prompt form that has an unbound control called "finddocnametxt" in
which the user inputs part of a document name. On the onclick event of a
command button the is a query which runs and finds all records where the
name of the document includes the characters the user has input and opens a
form based on that query showing the found records. I have an unbound
control on this form in which I want to appear the data the user has input
into the prompt form and use this as the forms data
=[Forms]![frmFindDocumentName]![finddocnametxt]
However all I get is the dreaded #Name
Anyone know how I can get round this?
TIA
Tony Williams
 
Do you close the form frmFindDocumentname after you have
opened the form on which the reference exists? If you do,
you could try populating the control before closing the
form e.g
DoCmd.OpenForm etc
Forms!{yourformname}!{yourcontrolname} = [finddocnametxt]
DoCmd.Close {currentformname}

Hope This Helps
Gerald Stanley MCSD
 
Gerald It seems to work BUT I get a message that says Can't assign a value
to this object which when I click on Ok it goes away and the control on my
form is complete???
The code I'm using is
Forms!frmDocumentName!NameParametertxt = [finddocnametxt]
Any ideas?? I'm obviously nearly there.
Tony
Gerald STanley said:
Do you close the form frmFindDocumentname after you have
opened the form on which the reference exists? If you do,
you could try populating the control before closing the
form e.g
DoCmd.OpenForm etc
Forms!{yourformname}!{yourcontrolname} = [finddocnametxt]
DoCmd.Close {currentformname}

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have a prompt form that has an unbound control called "finddocnametxt" in
which the user inputs part of a document name. On the onclick event of a
command button the is a query which runs and finds all records where the
name of the document includes the characters the user has input and opens a
form based on that query showing the found records. I have an unbound
control on this form in which I want to appear the data the user has input
into the prompt form and use this as the forms data
=[Forms]![frmFindDocumentName]![finddocnametxt]
However all I get is the dreaded #Name
Anyone know how I can get round this?
TIA
Tony Williams


.
 
Tony

That line of code works perfectly for me. Can you reply to
this thread with all the code in your command button click
event handler.

Many Thanks
Gerald Stanley MCSD
-----Original Message-----
Gerald It seems to work BUT I get a message that says Can't assign a value
to this object which when I click on Ok it goes away and the control on my
form is complete???
The code I'm using is
Forms!frmDocumentName!NameParametertxt = [finddocnametxt]
Any ideas?? I'm obviously nearly there.
Tony
Gerald STanley said:
Do you close the form frmFindDocumentname after you have
opened the form on which the reference exists? If you do,
you could try populating the control before closing the
form e.g
DoCmd.OpenForm etc
Forms!{yourformname}!{yourcontrolname} = [finddocnametxt]
DoCmd.Close {currentformname}

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have a prompt form that has an unbound control called "finddocnametxt" in
which the user inputs part of a document name. On the onclick event of a
command button the is a query which runs and finds all records where the
name of the document includes the characters the user has input and opens a
form based on that query showing the found records. I have an unbound
control on this form in which I want to appear the data the user has input
into the prompt form and use this as the forms data
=[Forms]![frmFindDocumentName]![finddocnametxt]
However all I get is the dreaded #Name
Anyone know how I can get round this?
TIA
Tony Williams


.


.
 
Thanks Gerald here it is
Private Sub cmdFindDocs_Click()
On Error GoTo Err_cmdFindDocs_Click

Dim stDocName As String
'Dim stLinkCriteria As String

stDocName = "frmDocumentName"
If IsNull(Me.finddocnametxt) Then MsgBox "Please enter Document Name"
Me.finddocnametxt.SetFocus
Cancel = True
If IsNull(Me.StartDatetxt) Then MsgBox "Please enter Start Date"
Me.StartDatetxt.SetFocus
Cancel = True
If IsNull(Me.EndDatetxt) Then MsgBox "Please enter End Date"
Me.EndDatetxt.SetFocus
Cancel = True
If Not IsNull(StartDatetxt) And Not IsNull(EndDatetxt) And Not
IsNull(finddocnametxt) Then
DoCmd.OpenForm stDocName
Forms!frmDocumentName!NameParametertxt = [finddocnametxt]

DoCmd.Close acForm, Me.Name
End If

Exit_cmdFindDocs_Click:
Exit Sub

Err_cmdFindDocs_Click:
MsgBox Err.Description
Resume Exit_cmdFindDocs_Click
End Sub
Tony
Gerald Stanley said:
Tony

That line of code works perfectly for me. Can you reply to
this thread with all the code in your command button click
event handler.

Many Thanks
Gerald Stanley MCSD
-----Original Message-----
Gerald It seems to work BUT I get a message that says Can't assign a value
to this object which when I click on Ok it goes away and the control on my
form is complete???
The code I'm using is
Forms!frmDocumentName!NameParametertxt = [finddocnametxt]
Any ideas?? I'm obviously nearly there.
Tony
Gerald STanley said:
Do you close the form frmFindDocumentname after you have
opened the form on which the reference exists? If you do,
you could try populating the control before closing the
form e.g
DoCmd.OpenForm etc
Forms!{yourformname}!{yourcontrolname} = [finddocnametxt]
DoCmd.Close {currentformname}

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have a prompt form that has an unbound control called
"finddocnametxt" in
which the user inputs part of a document name. On the
onclick event of a
command button the is a query which runs and finds all
records where the
name of the document includes the characters the user has
input and opens a
form based on that query showing the found records. I have
an unbound
control on this form in which I want to appear the data
the user has input
into the prompt form and use this as the forms data
=[Forms]![frmFindDocumentName]![finddocnametxt]
However all I get is the dreaded #Name
Anyone know how I can get round this?
TIA
Tony Williams


.


.
 
Tony

Nothing jumps out immediately. However, I have rewritten
the tests for efficiency and dropped the Cancel = True
statements as the Click event handler does not invoke a
Cancel parameter. Give this a try and see if the message
disappears

If IsNull(Me.finddocnametxt) Then
MsgBox "Please enter Document Name"
Me.finddocnametxt.SetFocus
ElseIf IsNull(Me.StartDatetxt) Then
MsgBox "Please enter Start Date"
Me.StartDatetxt.SetFocus
ElseIf IsNull(Me.EndDatetxt) Then
MsgBox "Please enter End Date"
Me.EndDatetxt.SetFocus
Else
DoCmd.OpenForm stDocName
Forms!frmDocumentName!NameParametertxt = Me.finddocnametxt
DoCmd.Close acForm, Me.Name
End If

Regards
Gerald Stanley MCSD
-----Original Message-----
Thanks Gerald here it is
Private Sub cmdFindDocs_Click()
On Error GoTo Err_cmdFindDocs_Click

Dim stDocName As String
'Dim stLinkCriteria As String

stDocName = "frmDocumentName"
If IsNull(Me.finddocnametxt) Then MsgBox "Please enter Document Name"
Me.finddocnametxt.SetFocus
Cancel = True
If IsNull(Me.StartDatetxt) Then MsgBox "Please enter Start Date"
Me.StartDatetxt.SetFocus
Cancel = True
If IsNull(Me.EndDatetxt) Then MsgBox "Please enter End Date"
Me.EndDatetxt.SetFocus
Cancel = True
If Not IsNull(StartDatetxt) And Not IsNull(EndDatetxt) And Not
IsNull(finddocnametxt) Then
DoCmd.OpenForm stDocName
Forms!frmDocumentName!NameParametertxt = [finddocnametxt]

DoCmd.Close acForm, Me.Name
End If

Exit_cmdFindDocs_Click:
Exit Sub

Err_cmdFindDocs_Click:
MsgBox Err.Description
Resume Exit_cmdFindDocs_Click
End Sub
Tony
Gerald Stanley said:
Tony

That line of code works perfectly for me. Can you reply to
this thread with all the code in your command button click
event handler.

Many Thanks
Gerald Stanley MCSD
-----Original Message-----
Gerald It seems to work BUT I get a message that says Can't assign a value
to this object which when I click on Ok it goes away and the control on my
form is complete???
The code I'm using is
Forms!frmDocumentName!NameParametertxt = [finddocnametxt]
Any ideas?? I'm obviously nearly there.
Tony
Do you close the form frmFindDocumentname after you have
opened the form on which the reference exists? If you do,
you could try populating the control before closing the
form e.g
DoCmd.OpenForm etc
Forms!{yourformname}!{yourcontrolname} = [finddocnametxt]
DoCmd.Close {currentformname}

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have a prompt form that has an unbound control called
"finddocnametxt" in
which the user inputs part of a document name. On the
onclick event of a
command button the is a query which runs and finds all
records where the
name of the document includes the characters the user has
input and opens a
form based on that query showing the found records. I have
an unbound
control on this form in which I want to appear the data
the user has input
into the prompt form and use this as the forms data
=[Forms]![frmFindDocumentName]![finddocnametxt]
However all I get is the dreaded #Name
Anyone know how I can get round this?
TIA
Tony Williams


.



.


.
 
Thanks Gerald but still get message although cod e seems to do what I want
it to do. I'm foxed! maybe there is another way of achieving the same thing
by using similar code on the opened form to populate the control and then
close the first form? I'll try that
Tony
Gerald Stanley said:
Tony

Nothing jumps out immediately. However, I have rewritten
the tests for efficiency and dropped the Cancel = True
statements as the Click event handler does not invoke a
Cancel parameter. Give this a try and see if the message
disappears

If IsNull(Me.finddocnametxt) Then
MsgBox "Please enter Document Name"
Me.finddocnametxt.SetFocus
ElseIf IsNull(Me.StartDatetxt) Then
MsgBox "Please enter Start Date"
Me.StartDatetxt.SetFocus
ElseIf IsNull(Me.EndDatetxt) Then
MsgBox "Please enter End Date"
Me.EndDatetxt.SetFocus
Else
DoCmd.OpenForm stDocName
Forms!frmDocumentName!NameParametertxt = Me.finddocnametxt
DoCmd.Close acForm, Me.Name
End If

Regards
Gerald Stanley MCSD
-----Original Message-----
Thanks Gerald here it is
Private Sub cmdFindDocs_Click()
On Error GoTo Err_cmdFindDocs_Click

Dim stDocName As String
'Dim stLinkCriteria As String

stDocName = "frmDocumentName"
If IsNull(Me.finddocnametxt) Then MsgBox "Please enter Document Name"
Me.finddocnametxt.SetFocus
Cancel = True
If IsNull(Me.StartDatetxt) Then MsgBox "Please enter Start Date"
Me.StartDatetxt.SetFocus
Cancel = True
If IsNull(Me.EndDatetxt) Then MsgBox "Please enter End Date"
Me.EndDatetxt.SetFocus
Cancel = True
If Not IsNull(StartDatetxt) And Not IsNull(EndDatetxt) And Not
IsNull(finddocnametxt) Then
DoCmd.OpenForm stDocName
Forms!frmDocumentName!NameParametertxt = [finddocnametxt]

DoCmd.Close acForm, Me.Name
End If

Exit_cmdFindDocs_Click:
Exit Sub

Err_cmdFindDocs_Click:
MsgBox Err.Description
Resume Exit_cmdFindDocs_Click
End Sub
Tony
Gerald Stanley said:
Tony

That line of code works perfectly for me. Can you reply to
this thread with all the code in your command button click
event handler.

Many Thanks
Gerald Stanley MCSD
-----Original Message-----
Gerald It seems to work BUT I get a message that says
Can't assign a value
to this object which when I click on Ok it goes away and
the control on my
form is complete???
The code I'm using is
Forms!frmDocumentName!NameParametertxt = [finddocnametxt]
Any ideas?? I'm obviously nearly there.
Tony
Do you close the form frmFindDocumentname after you have
opened the form on which the reference exists? If you do,
you could try populating the control before closing the
form e.g
DoCmd.OpenForm etc
Forms!{yourformname}!{yourcontrolname} = [finddocnametxt]
DoCmd.Close {currentformname}

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have a prompt form that has an unbound control called
"finddocnametxt" in
which the user inputs part of a document name. On the
onclick event of a
command button the is a query which runs and finds all
records where the
name of the document includes the characters the user has
input and opens a
form based on that query showing the found records. I have
an unbound
control on this form in which I want to appear the data
the user has input
into the prompt form and use this as the forms data
=[Forms]![frmFindDocumentName]![finddocnametxt]
However all I get is the dreaded #Name
Anyone know how I can get round this?
TIA
Tony Williams


.



.


.
 
Gerald, my grey cells are at last defeating me at 60 years of age. I've
realised what the mistake was! On the form to be opened I'd left some
parameter code in the control that I'm trying to populate and obviously it
was screwing up the VBA code. Why did I miss that? I can only say that my
concentration levels get a little screwed up as well at the end of a long
day these days.
Thanks a lot for your input tho and sorry to have wasted any of your time
Tony
Gerald Stanley said:
Tony

Nothing jumps out immediately. However, I have rewritten
the tests for efficiency and dropped the Cancel = True
statements as the Click event handler does not invoke a
Cancel parameter. Give this a try and see if the message
disappears

If IsNull(Me.finddocnametxt) Then
MsgBox "Please enter Document Name"
Me.finddocnametxt.SetFocus
ElseIf IsNull(Me.StartDatetxt) Then
MsgBox "Please enter Start Date"
Me.StartDatetxt.SetFocus
ElseIf IsNull(Me.EndDatetxt) Then
MsgBox "Please enter End Date"
Me.EndDatetxt.SetFocus
Else
DoCmd.OpenForm stDocName
Forms!frmDocumentName!NameParametertxt = Me.finddocnametxt
DoCmd.Close acForm, Me.Name
End If

Regards
Gerald Stanley MCSD
-----Original Message-----
Thanks Gerald here it is
Private Sub cmdFindDocs_Click()
On Error GoTo Err_cmdFindDocs_Click

Dim stDocName As String
'Dim stLinkCriteria As String

stDocName = "frmDocumentName"
If IsNull(Me.finddocnametxt) Then MsgBox "Please enter Document Name"
Me.finddocnametxt.SetFocus
Cancel = True
If IsNull(Me.StartDatetxt) Then MsgBox "Please enter Start Date"
Me.StartDatetxt.SetFocus
Cancel = True
If IsNull(Me.EndDatetxt) Then MsgBox "Please enter End Date"
Me.EndDatetxt.SetFocus
Cancel = True
If Not IsNull(StartDatetxt) And Not IsNull(EndDatetxt) And Not
IsNull(finddocnametxt) Then
DoCmd.OpenForm stDocName
Forms!frmDocumentName!NameParametertxt = [finddocnametxt]

DoCmd.Close acForm, Me.Name
End If

Exit_cmdFindDocs_Click:
Exit Sub

Err_cmdFindDocs_Click:
MsgBox Err.Description
Resume Exit_cmdFindDocs_Click
End Sub
Tony
Gerald Stanley said:
Tony

That line of code works perfectly for me. Can you reply to
this thread with all the code in your command button click
event handler.

Many Thanks
Gerald Stanley MCSD
-----Original Message-----
Gerald It seems to work BUT I get a message that says
Can't assign a value
to this object which when I click on Ok it goes away and
the control on my
form is complete???
The code I'm using is
Forms!frmDocumentName!NameParametertxt = [finddocnametxt]
Any ideas?? I'm obviously nearly there.
Tony
Do you close the form frmFindDocumentname after you have
opened the form on which the reference exists? If you do,
you could try populating the control before closing the
form e.g
DoCmd.OpenForm etc
Forms!{yourformname}!{yourcontrolname} = [finddocnametxt]
DoCmd.Close {currentformname}

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have a prompt form that has an unbound control called
"finddocnametxt" in
which the user inputs part of a document name. On the
onclick event of a
command button the is a query which runs and finds all
records where the
name of the document includes the characters the user has
input and opens a
form based on that query showing the found records. I have
an unbound
control on this form in which I want to appear the data
the user has input
into the prompt form and use this as the forms data
=[Forms]![frmFindDocumentName]![finddocnametxt]
However all I get is the dreaded #Name
Anyone know how I can get round this?
TIA
Tony Williams


.



.


.
 
Back
Top