Jumat, 27 Januari 2012

Re: [MS_AccessPros] subform questions

 

Hi Jacie,

before you move the record pointer, do this:

'save record if changes have been made

if me.dirty then me.dirty = false

~~~~~~~~~~~~~~~~~~~

"dirty" is a form property that gets set to TRUE if a record has changes that need to be saved
 
if me.dirty then
is the same thing as
if me.dirty=True then

me.dirty = false
is just another way to save a record

~~~~~~~~~~~~~~~~~~~

perhaps the problem is not that you can't go to the specified record, but you can't get off the record you are on ...

Warm Regards,
Crystal

Microsoft MVP
remote programming and training

Access Basics by Crystal
http://www.AccessMVP.com/strive4peace
Free 100-page book that covers essentials in Access

 *
   (: have an awesome day :)
 *

________________________________
From: Jackie Diekmann

John,
Tried your code.  Gave me, you can't go to the specified record.  Any ideas?
Jackie

--- On Fri, 1/27/12, John Viescas

Jackie-

Then do:

Me.[TCDETAILS].Form!addmode.Visible = True

Me.[TCDETAILS].Enabled = True
Me.[TCDETAILS].Form!empid = Me.selempid
Me.[TCDETAILS].Form!wkend = Date - Weekday(Date) + 1

Me.[TCDETAILS].Form!wkend.SetFocus
DoCmd.GoToRecord , , acNewRed

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Lahaina, HI)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Jackie Diekmann
Sent: Friday, January 27, 2012 6:37 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: RE: [MS_AccessPros] subform questions

John,
The button is on the outer form. It will enable the form for either a new record or display existing records. From there, I want them to add their timesheet information.

Thanks,
Jackie

--- On Wed, 1/25/12, John Viescas <john@viescas.com> wrote:

From: John Viescas <john@viescas.com>
Subject: RE: [MS_AccessPros] subform questions
To: MS_Access_Professionals@yahoogroups.com
Date: Wednesday, January 25, 2012, 1:30 PM

Jackie-

Is this code running on the outer form or in the subform?

In general, to reference a form inside a subform control, you must use:

Forms!NameOfOuterForm!NameOfSubformControl.Form

Note that I say "NameOfSubformControl" which is not necessarily the same as the
name of the form inside the control.

So, the first line should read:

Forms![employee timecard]![TCDETAILS].Form!addmode.Visible = True

.. assuming the name of the subform control is TCDETAILS. If this is in code
behind the outer form, you could also use:

Me.TCDETAILS.Form!addmode.Visible = True

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Lahaina, HI)

-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of jdiek_2000
Sent: Wednesday, January 25, 2012 9:00 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] subform questions

Hi,
I am trying to add a record to an employee timecard. Details:

main form is call employee timecard. Its control is employees. This table
contains the employee id and name.

subform is called tcdetails. Its control is timecard. It is also a continuous
form. I want the employee to see their timecard and all lines at one time.

I want to control all updates, inserts, etc. via VBA. I do not want them to go
to the next record without saving the record.

I have them finding the employee using a combo textbox. After they select the
employee, the main form displays the name, employee id and division. This form
becomes enabled after they have selected the employee.

Next the employee will click the new button. This button I want to enable the
subform tcdetails and go to a new record. I want them to save before they click
on the next record to add to the timecard table.

I can not get it to work correctly. I get form not opened using this code:

Private Sub new_wk_Click()
On Error GoTo Err_new_rec_Click

Forms![employee timecard]![TCDETAILS]!addmode.Visible = True

Forms![employee timecard]![TCDETAILS].Enabled = True
Forms![employee timecard]![TCDETAILS]!empid = Forms![employee timecard].selempid
Forms![employee timecard]![TCDETAILS]!wkend = Date - Weekday(Date) + 1

Forms![employee timecard]![TCDETAILS]!wkend.SetFocus
DoCmd.GoToRecord acDataForm, "tcdetails", acNewRec <--error occurs here

Exit_new_rec_Click:
Exit Sub

Err_new_rec_Click:
MsgBox Err.Description
Resume Exit_new_rec_Click
End Sub

Thanks for your help. I normally don't do it this way but keep being told I
need to do it using the tables.

Jackie

------------------------------------

Yahoo! Groups Links

[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links

[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___

Tidak ada komentar:

Posting Komentar