Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-04-2019, 11:18 AM   #1
dcavaiani
Newly Registered User
 
Join Date: May 2014
Location: Appleton, WI
Posts: 311
Thanks: 220
Thanked 10 Times in 10 Posts
dcavaiani is on a distinguished road
Losing formatting on form after table updated

I have events coded on the form fields as well as some conditional formatting. After I run VBA code to update records in the related Table and then return to the Form, these controls are not showing. When I go into the properties, the events and conditional stuff is still there, and then after saving the form, the controls, etc. show up ??? Very weird !!!

dcavaiani is offline   Reply With Quote
Old 12-04-2019, 11:22 AM   #2
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,486
Thanks: 58
Thanked 1,419 Times in 1,400 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Losing formatting on form after table updated

Do you think maybe it's the code that's causing it? If so, what does your code look like?
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
dcavaiani (12-04-2019)
Old 12-04-2019, 11:28 AM   #3
dcavaiani
Newly Registered User
 
Join Date: May 2014
Location: Appleton, WI
Posts: 311
Thanks: 220
Thanked 10 Times in 10 Posts
dcavaiani is on a distinguished road
Re: Losing formatting on form after table updated

Code:
Sub prep()
On Error GoTo ErrorHandler
Dim db As DAO.Database
Dim timecards As DAO.Recordset
Dim myDate As Variant
Dim dated As Date
   Set db = CurrentDb
   Set rstprep = db.OpenRecordset("timecards")
rstprep.MoveFirst
myDate = InputBox("Enter New Week's Saturday Start Date in Format: MM/DD/YYYY")
Do Until rstprep.EOF

If rstprep!Field1 = "Dates" Then
rstprep.Edit
dated = DateValue(myDate)
rstprep!sain = dated
rstprep!suin = DateAdd("d", 1, dated)
rstprep!moin = DateAdd("d", 2, dated)
rstprep!tuin = DateAdd("d", 3, dated)
rstprep!wein = DateAdd("d", 4, dated)
rstprep!thin = DateAdd("d", 5, dated)
rstprep!frin = DateAdd("d", 6, dated)
rstprep.Update
      End If
      
      If rstprep!Field1 = "Customer" Or rstprep!Field1 = "Am" Or rstprep!Field1 = "Pm" Or rstprep!Field1 = "Daily" Or rstprep!Field1 = "Weekly" Or rstprep!Field1 = "TOTALS" Then
         rstprep.Edit
         
   rstprep!sain = ""
   rstprep!saout = ""
   rstprep!suin = ""
   rstprep!suout = ""
   rstprep!moin = ""
   rstprep!moout = ""
   rstprep!tuin = ""
   rstprep!tuout = ""
   rstprep!wein = ""
   rstprep!weout = ""
   rstprep!thin = ""
   rstprep!thout = ""
   rstprep!frin = ""
   rstprep!frout = ""
rstprep.Update
      End If
      
      rstprep.MoveNext
   Loop
'_________________________________
On Error GoTo ErrorHandler
ErrorHandlerExit:
    Exit Sub
ErrorHandler:
    If Err = 3021 Then    ' no current record
            Else
'        MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
        Resume ErrorHandlerExit
    End If
End Sub

dcavaiani is offline   Reply With Quote
Old 12-04-2019, 11:33 AM   #4
dcavaiani
Newly Registered User
 
Join Date: May 2014
Location: Appleton, WI
Posts: 311
Thanks: 220
Thanked 10 Times in 10 Posts
dcavaiani is on a distinguished road
Re: Losing formatting on form after table updated

Quote:
Originally Posted by theDBguy View Post
Do you think maybe it's the code that's causing it? If so, what does your code look like?
How's that Christmas Tree lookin'
dcavaiani is offline   Reply With Quote
Old 12-04-2019, 11:35 AM   #5
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,486
Thanks: 58
Thanked 1,419 Times in 1,400 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Losing formatting on form after table updated

Quote:
Originally Posted by dcavaiani View Post
How's that Christmas Tree lookin'
It looks nice. Thanks. How do you execute this code/sub, which event do you use?
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
dcavaiani (12-04-2019)
Old 12-04-2019, 11:38 AM   #6
dcavaiani
Newly Registered User
 
Join Date: May 2014
Location: Appleton, WI
Posts: 311
Thanks: 220
Thanked 10 Times in 10 Posts
dcavaiani is on a distinguished road
Re: Losing formatting on form after table updated

Quote:
Originally Posted by theDBguy View Post
It looks nice. Thanks. How do you execute this code/sub, which event do you use?
Have not figured that point out just yet. Now, I just open the module and click the "run" which executes it. Not too smart about all that "integration" yet but maybe it will/has to be run from a Macro ?
dcavaiani is offline   Reply With Quote
Old 12-04-2019, 12:23 PM   #7
dcavaiani
Newly Registered User
 
Join Date: May 2014
Location: Appleton, WI
Posts: 311
Thanks: 220
Thanked 10 Times in 10 Posts
dcavaiani is on a distinguished road
Re: Losing formatting on form after table updated

I changed the code to a Function and that seems to correct this. Could that be it? Really confused on sub vs function ...

dcavaiani is offline   Reply With Quote
Old 12-04-2019, 12:25 PM   #8
theDBguy
Iím here to help
 
theDBguy's Avatar
 
Join Date: Oct 2018
Location: SunnySandyEggo
Posts: 6,486
Thanks: 58
Thanked 1,419 Times in 1,400 Posts
theDBguy has a spectacular aura about theDBguy has a spectacular aura about
Re: Losing formatting on form after table updated

Quote:
Originally Posted by dcavaiani View Post
I changed the code to a Function and that seems to correct this. Could that be it? Really confused on sub vs function ...
There's a few differences, but glad to hear you got it sorted out. Cheers!
__________________
Just my 2 cents...

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
theDBguy is online now   Reply With Quote
The Following User Says Thank You to theDBguy For This Useful Post:
dcavaiani (12-04-2019)
Old 12-04-2019, 02:21 PM   #9
Mark_
Longboard on the internet
 
Join Date: Sep 2017
Location: Not the middle of no where, but I can see the road to it from my house.
Posts: 2,112
Thanks: 20
Thanked 400 Times in 393 Posts
Mark_ will become famous soon enough Mark_ will become famous soon enough
Re: Losing formatting on form after table updated

dcavaiani,

To be clear, each record holds 14 date/times so one record is used for one week?
What happens if a person has to clock out for part of their normal shift?

You may find it easier to use one record per in/out, thus allowing you to have an employee clock in at 8am, clock out for lunch as 12:30pm, clock back in at 1:30pm, then clock out for the day at 5pm. This would also handle if the employee came back at 8pm and clocked in for an hour to handle... STUFF...

Mark_ is offline   Reply With Quote
The Following User Says Thank You to Mark_ For This Useful Post:
dcavaiani (12-04-2019)
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Form not updating. Table is updated. Zak14 Forms 20 07-17-2014 02:47 AM
Losing Formatting & Pic Position in Rich Text Template Automated Send Soule Modules & VBA 2 03-13-2012 06:40 PM
Exporting reports to Word without losing formatting irish2556 Reports 0 03-19-2009 04:51 AM
losing formatting jive6243 Reports 4 01-17-2002 07:32 AM
Output Report Without Losing Formatting - Help! Tracy Reports 1 10-19-2001 03:07 AM




All times are GMT -8. The time now is 05:33 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World