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

problem filling a form automatically 1

Status
Not open for further replies.

DLynnTX

IS-IT--Management
Dec 9, 2004
67
US
I have been doing fine with autofilling forms that are part of a tab and moving between tabs, etc. But the form I'm having problems with now is a separate form that is opened when a button is pressed (Create RMA). This is the code I have tied to the button on the OnClick event.
Private Sub Command27_Click()
On Error GoTo Err_Command27_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "UnitRepairHx"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Me.[UnitRepairHx].Form![UnitID] = Forms!Main.WorkOrders![UnitID]
Me.[UnitRepairHx].Form![DateCreated] = Date
Me.[UnitRepairHx].Form![WorkorderID#] = Forms!Main.WorkOrders![WorkorderID#]
Me.[UnitRepairHx].Form![ProblemDescription] = Forms!Main.WorkOrders![ProblemDescription]


Exit_Command27_Click:
Exit Sub

Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click

End Sub

When I click the button I get the following error:
"Databasename can't find the field '|' referred to in your expression"

Any ideas what I'm doing wrong?
Thank you in advance. :)
 
What about using a period instead of exclamation point? Dot instead of Bash notation?

Code:
Me.[/higlight][UnitRepairHx].Form[highlight]![/highlight][UnitID] = Forms!Main.WorkOrders[highlight]![/highlight][UnitID]

I think that bash should be dot notation there. [.] instead of [!]

----

I also think you don't need ".Form" in the phrase "Me.Form..." When you use "Me.", you are referring to the Form already. The only reason you should need "Form." after that (I think) is when you're dealing with subforms.

I've not tested this, but give it a try.

Also, the material at the following link appears to be a good reference for this type of coding:

--

"If to err is human, then I must be some kind of human!" -Me
 
I'm not sure if this is what you were talking about...

stDocName = "UnitRepairHx"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord , , acNewRec
Me.[UnitRepairHx].[UnitID] = Forms!Main.WorkOrders![UnitID]
Me.[UnitRepairHx].[DateCreated] = Date
Me.[UnitRepairHx].[WorkorderID#] = Forms!Main.WorkOrders![WorkorderID#]
Me.[UnitRepairHx].[ProblemDescription] = Forms!Main.WorkOrders![ProblemDescription]

If it is, it didn't work... if I missed the point, please help me :)
 
I believe you need to use Forms![UnitRepairHx]![UnitID]assuming the button is on the form Main.
 
The button is actually on a subform (Workorders)
 
Assuming that UnitRepairHx is a seperate form you can't use ME from your subform to refer to it.
 
Ok - headed to the clients now - I'll try that when I get there. Thank you.
 
The button is actually on a subform (Workorders)
DoCmd.OpenForm "UnitRepairHx"
DoCmd.GoToRecord acDataForm, "UnitRepairHx", acNewRec
Forms!UnitRepairHx![UnitID] = Me![UnitID]
Forms!UnitRepairHx![DateCreated] = Date
Forms!UnitRepairHx![WorkorderID#] = Me![WorkorderID#]
Forms!UnitRepairHx![ProblemDescription] = Me![ProblemDescription]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I just had a chance to try this - PHV - that weren't PERFECTLY. Once again, you came through for me. Thank you so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top