UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Open Form to New Record    
 
   
snsd
post Jan 4 2005, 01:50 PM
Post #1

UtterAccess Veteran
Posts: 454
From: Markham, Ontario, Canada



Hi:

Simple question. I have a command button on a menu form that opens another form. See the code below. When the form opens, it always displays the first record. I want a blank new record to be displayed ready for data input. What do I add to my code to do so.

Thanks in advance for your help.

Dave

Code
____________
Private Sub cmdResponseReceivedLogging_Click()
On Error GoTo Err_cmdResponseReceivedLogging_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmReceivedLogging"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdResponseReceivedLogging_Click:
Exit Sub

Err_cmdResponseReceivedLogging_Click:
MsgBox Err.Description
Resume Exit_cmdResponseReceivedLogging_Click

End Sub
Go to the top of the page
 
+
HunterOfTheShado...
post Jan 4 2005, 01:59 PM
Post #2

UtterAccess Veteran
Posts: 367
From: South TX



I believe that setting the forms Data entry option to YES will do the trick..

HTH

-hunter
Go to the top of the page
 
+
snsd
post Jan 4 2005, 02:03 PM
Post #3

UtterAccess Veteran
Posts: 454
From: Markham, Ontario, Canada



Thanks Hunter. Thought I was getting good at this program... Oh well.

Dave (IMG:http://www.utteraccess.com/forum/style_emoticons/default/frown.gif)
Go to the top of the page
 
+
dannyseager
post Jan 4 2005, 02:12 PM
Post #4

UtterAccess VIP
Posts: 13,031
From: Leicester, UK



you could have also added

DoCmd.GoToRecord acDataForm, stDocName, acNewRec

to the command after the line to open the form.
Go to the top of the page
 
+
snsd
post Jan 4 2005, 02:17 PM
Post #5

UtterAccess Veteran
Posts: 454
From: Markham, Ontario, Canada



OK. I switched the "data entry" option to YES - but now I'm not able to view records that I've already entered to the form. So, I got what I wanted but lost something I liked! In other words, I want to have the ability to view existing records in the form but when opening the form have it go to the "new record" input screen. Any further ideas?

Thanks,

Dave
Go to the top of the page
 
+
snsd
post Jan 4 2005, 02:22 PM
Post #6

UtterAccess Veteran
Posts: 454
From: Markham, Ontario, Canada



Thanks Danny!!! Works perfect. You must have read my mind as you responded to the question I just posted as I was writing it.

Dave
Go to the top of the page
 
+
dannyseager
post Jan 4 2005, 02:23 PM
Post #7

UtterAccess VIP
Posts: 13,031
From: Leicester, UK



you're welcome

Glad to help
Go to the top of the page
 
+
HunterOfTheShado...
post Jan 4 2005, 02:38 PM
Post #8

UtterAccess Veteran
Posts: 367
From: South TX



Dan's the man!!

You actually helped clear up a problem i was just starting to have with opening a new form for Data Entry!!!

Thanks from me as well

(IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif)

-hunter
Go to the top of the page
 
+
snsd
post Jan 7 2005, 10:26 AM
Post #9

UtterAccess Veteran
Posts: 454
From: Markham, Ontario, Canada



Another question in regards to this issue....

When my database opens, I have an "autoexec" macro open this form. As with the command button question, how do I get a "blank form ready for input" to appear when I first open the database versus the first record in the database.

Thanks in advance.

Dave
Go to the top of the page
 
+
HunterOfTheShado...
post Jan 7 2005, 10:33 AM
Post #10

UtterAccess Veteran
Posts: 367
From: South TX



Dave,

Putting Danny's code in the On Load event of the form might do the trick. I haven't tested this yet though. try it and post back the result.

HTH

-hunter
Go to the top of the page
 
+
snsd
post Jan 7 2005, 10:52 AM
Post #11

UtterAccess Veteran
Posts: 454
From: Markham, Ontario, Canada



Bingo! Great suggestion. Works great. Thank-you. Please let me know if I could have done it any differently. Dave

Here's what it looks like.

CODE
Private Sub Form_Load()
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmMasterInput"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord acDataForm, stDocName, acNewRec

End Sub
Go to the top of the page
 
+
HunterOfTheShado...
post Jan 7 2005, 11:40 AM
Post #12

UtterAccess Veteran
Posts: 367
From: South TX



I don't know if you need anything but the last line:

DoCmd.GoToRecord acDataForm, stDocName, acNewRec

put a single quote ' in front of the other lines close the VBA window, save the form and try to reload it to see if the single line will do it.

-hunter
Go to the top of the page
 
+
snsd
post Jan 7 2005, 11:44 AM
Post #13

UtterAccess Veteran
Posts: 454
From: Markham, Ontario, Canada



Hunter:

I tried that and got a "Variable not defined error" on " stDocName". Any other ideas?

Dave
Go to the top of the page
 
+
mhourie
post Jan 7 2005, 11:47 AM
Post #14

UtterAccess Addict
Posts: 199
From: NV, USA



Try

DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
Go to the top of the page
 
+
snsd
post Jan 7 2005, 11:50 AM
Post #15

UtterAccess Veteran
Posts: 454
From: Markham, Ontario, Canada



Works perfectly. Thanks for the help.

Dave
Go to the top of the page
 
+
HunterOfTheShado...
post Jan 7 2005, 11:50 AM
Post #16

UtterAccess Veteran
Posts: 367
From: South TX



sorry...mhourie is correct. That should be your variable error (me.name).

--hunter
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 20th June 2013 - 02:37 AM