Re: Proper way to save a record

Tech-Archive recommends: Fix windows errors by optimizing your registry



> DoCmd.Save acForm, "FCycDoseVitalAmp"

The above command actually saves the form, and not the data. Clearly, you
don't need, nor want to save the form, so, dump the above line, it is NOT
needed.

> DoCmd.OpenForm "FCycDoseVitalAmp", acNormal

Why are you opening the form when it is already open? Again, you don't need
to open a form that is already open. So, dump the above line, it is NOT
needed.

> DoCmd.GoToRecord acDataForm, "FCycDoseVitalAmp", acNewRec

The above looks fine. Remember, if your code, or your user navigates to
another record, ms-access thoughtfully, and kindly saves the current data
for you

> DoCmd.GoToControl "course"

The above is also fine. I tend to prefer using the setfocus method of a
control., such as

course.SetFocus

I prefer the above since it implies that I am working with a control, and
you also get inteli-sense as you type it. Further, if you miss type the
name, and compile your code, you get a error. With the docmd, you only get
the error at RUNTIME, and so the compiler can't check your syntax for you.
As developer, you no doubt compile your code after any changes you make, and
thus using methods of control are checked at compile time. (setfocus is a
method of the control called course, and this is checked for you during
compile time).

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@xxxxxxx
http://www.members.shaw.ca/AlbertKallal


.



Relevant Pages

  • Re: Difficulties programming a command button
    ... Twice when I tried to compile Access hung and I just ... and selecting 'Yes' opens the Excel file. ... I doubled checked the sheet names to what I had in the ... The name for the control for the equipment is “txtEquipment”. ...
    (microsoft.public.access.modulesdaovba)
  • Re: User Controls are dissapearing at designTime
    ... go into configuration manager and set all control projects to compile ... The user control is embedded in the project (a ... > reference in the project is not pointing anymore to binary. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Access Violation Exception
    ... In VB6, in the project's properties, go to the Compile tab and select ... This will create a PDB file when you compile ... where the error occurred in the custom control. ... > I have a vb6 app with various custom controls. ...
    (microsoft.public.vb.winapi)
  • Re: Access Violation Exception
    ... This will create a PDB file when you compile ... > where the error occurred in the custom control. ... >> I have a vb6 app with various custom controls. ... App enters into a loop where it displays the exception error and it ...
    (microsoft.public.vb.winapi)
  • Re: EXE hangs!
    ... I have been logging to a textbox on my application. ... to a property of an ActiveX control. ... I was checking the state of the DNS microphone control at a somewhat ... compiles into, so that I can write things that compile efficiently. ...
    (microsoft.public.vb.enterprise)