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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

On Click - what's missing? 2

Status
Not open for further replies.

ProtegeV2

Technical User
Sep 9, 2004
40
0
0
CA
I don't know if you need this, but the form's On Current is:
Private Sub Form_Current()

Me![txtDocInv] = DLookup("[SumofInvoice Amount]", "[qryInvoicedTD]", "[Docket #]=" & Me![Docket #])

Me![txtEstimate] = DLookup("[SumofTotal]", "[qryEstimates]", "[Docket]=" & Me![Docket #])

End Sub

I'm adding a button that allows the user to switch from this form to the corresponding [docket #] in the original "Project request form". Can you tell me what I am missing in the button's On Click:

Private Sub Command99_Click()
On Error GoTo Err_Command99_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim strWhere As String

strWhere = "[Docket #]=" & Me.txtDocket
stDocName = "Project Request Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command99_Click:
Exit Sub

Err_Command99_Click:
MsgBox Err.Description
Resume Exit_Command99_Click

End Sub


The run-time error is:

Private Sub Form_Open(Cancel As Integer)

Application.SetOption "any part of field", 1

End Sub

??
Thanks
 
There's no property with that name, it is probably:

[tt]Application.SetOption "default find/replace behavior", 1[/tt]

Roy-Vidar
 
I want the "Project request form" to open the same record displayed in the tracking form. It opened record 1 on the project request form.

Thanks.
 
If there's code in a post, I don't bother reading it to look for errors, I read the top, and if that doesn't provide a question I go to the bottom and look. Here there was something relating to a run time error - is that solved?

By the "symptoms" it seems you are "switching" between open forms. Then the On open event will not fire. If that's the case, you'll probably need something like this:

[tt]dim frm as form
dim rs as dao.recordset
...
strWhere = "[Docket #]=" & Me.txtDocket
stDocName = "Project Request Form"
if currentproject.allforms(stDocName).isloaded then
set frm=forms(stdocmname)
set rs=frm.recordsetclone
rs.findfirst strwhere
if not rs.nomatch then frm.bookmark=rs.bookmark
set rs=nothing
frm.setfocus
set frm=nothing
else
DoCmd.OpenForm stDocName, , , stLinkCriteria
end if[/tt]

- typed not tested

But then again, it might be just that you haven't saved the current record, then not having a record yet with that number in the table, might be the only thing you need is

[tt]if me.dirty then
me.dirty = false
' or your favourite save recod command
end if[/tt]

before trying to open the other form?

Having a bit of information does help...

Roy-Vidar
 
How are ya ProtegeV2 . . . . .

First, make corrections in [purple]purple[/purple]:
Code:
[blue]    strWhere = "[Docket #]= [purple][b]'[/b][/purple]" & Me.txtDocket & [purple][b]"'"[/b][/purple]
    stDocName = "[purple][b][[/b][/purple]Project Request Form[purple][b]][/b][/purple]"
    DoCmd.OpenForm stDocName, , , stLinkCriteria[/blue]
Now
ProtegeV2 said:
[blue]Application.SetOption "any part of field", 1[/blue]
Have no Idea what your attempting to do here . . . however:
Microsoft said:
[blue]SetOption Method
Temporarily overrides settings for [purple]Microsoft Jet Database Engine Key[/purple] in the windows registry ([purple]Microsoft Jet WorkSpaces Only[/purple])[/blue]
[blue]You were saying ?[/blue]

Calvin.gif
See Ya! . . . . . .
 
Thanks, but it still opens [Project Request Form] on record 1. Do I need a DLookup or something to get the matching "[docket #].[Project Request Form]"?
 
DoCmd.OpenForm stDocName, , , strWhere

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Now I'm getting a message that the form name is misspelled or doesn't exist. It is spelled correctly...

Private Sub Command99_Click()
On Error GoTo Err_Command99_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim strWhere As String

strWhere = "[Docket #]= '" & Me.txtDocket & "'"
stDocName = "[Project Request Form]"
DoCmd.OpenForm stDocName, , , strWhere

Exit_Command99_Click:
Exit Sub

Err_Command99_Click:
MsgBox Err.Description
Resume Exit_Command99_Click

End Sub


 
ProtegeV2 . . . . .

RoyVidar is right about the brackets (my err). There is no form [purple]"[Project Request Form]"[/purple].

For clarity . . . [blue]Docket # is testx/numeric?[/blue]

Calvin.gif
See Ya! . . . . . .
 
I should have mentioned that I tried taking off the brackets and received the following message:

The OpenForm action was cancelled.

You used a method of the DoCmd object to carry out an action in Visual Basic but then clicked Cancel in a dialog box.

Yes, [Docket #] is a number field size: double. Thank you.
 
And this ?
strWhere = "[Docket #]=" & Me.txtDocket
stDocName = "Project Request Form"
DoCmd.OpenForm stDocName, , , strWhere

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top