|
-
Jun 21st, 2007, 10:16 AM
#1
Thread Starter
Member
[RESOLVED] Access: Sub or Function not defined
I have two separate forms (not subforms or anything. just two normal forms), one of which is linked to my data table, and the other one is a sort of welcome screen which allows the user to find records and create new records. Unfortunately, the creating of records isn't working as well as I'd like.
The way I have it set up right now is the user types either the name they want to search for or the name they want to add, and clicks the appropriate button.
Here's the welcome screen code:
Code:
Sub cmdNew_Click()
txtName.SetFocus
newEmployee = txtName.Text
DoCmd.OpenForm "Page1"
DoCmd.GoToRecord acDataForm, "Page1, acNewRec"
populateNewRecord newEmployee
End Sub
and the data form code:
Code:
Public Sub populateNewRecord(newEmployee As String)
txtEmployeeName.Text = newEmployee
End Sub
As you can see, in an effort to automatically populate the name, I'm saving the contents of the text box, and sending it off to a function in the data form. Unfortunately, it's telling me that it's not defined, and I have no idea how to fix it. :/
-
Jun 21st, 2007, 10:20 AM
#2
Member
Re: Access: Sub or Function not defined
Just taken another look at the code. Try:
vb Code:
Sub cmdNew_Click()
txtName.SetFocus
newEmployee = txtName.Text
DoCmd.OpenForm "Page1"
DoCmd.GoToRecord acDataForm, "Page1", acNewRec
populateNewRecord(newEmployee)
End Sub
~ James
-
Jun 21st, 2007, 10:32 AM
#3
Thread Starter
Member
Re: Access: Sub or Function not defined
-
Jun 21st, 2007, 11:00 AM
#4
Member
Re: Access: Sub or Function not defined
OK, I've just duplicated what you have here:
Move:
vb Code:
Public Sub populateNewRecord(newEmployee As String)
txtEmployeeName.Text = newEmployee
End Sub
to a new module. Save it, watch it run (I hope).
(Make sure you make those other changes I've suggested above, otherwise they will cause problems too).
-
Jun 21st, 2007, 02:08 PM
#5
Thread Starter
Member
Re: Access: Sub or Function not defined
Thanks! It's working great now.
(Although I can't believe I had the quotes in my GoToRecord line so messed up... )
-
Jun 21st, 2007, 04:50 PM
#6
Member
Re: [RESOLVED] Access: Sub or Function not defined
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|