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

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> If Then Macro Criteria Issue, Access 2013    
 
   
wagman
post Jun 20 2019, 01:54 PM
Post#1



Posts: 250
Joined: 12-March 08



I am creating a very simple db for people to choose their name and click a button. The first time on a date, they click, a new record is created with the current date and the current time in. The next time they click, it will put the current time in another field, in the same record. That way there is a date with a time in and a time out.

What is perplexing me is the Macro event I have built for the button click.

When the db is opened, a form is presented with a combo box and a button. That is the only UI the person will see. They will use the combo box to select their name and click the button. On the button click a form will open that has fields for RecordID, StaffID, Date, and one extra field (named Staff). The form is based on a simple query that filters by the StaffID select via the combo box and the current date. The form will either have mostly blank fields, if the person has not signed in that day, or the current day's record of them. If the Date field is blank, the extra field will be filled with "New", if the Date field has anything in it, the extra field will populate with "Old".

So, I have two forms...one for In and one for Out. When the button is clicked, via a macro, I have the above form open and then I have an If/Else statement that will open one of the other forms, In or Out. They are automated and I then have whichever opens to close and then have the above form close as well.

The initial If statement, in the macro, is super simple "If [Forms]![Form1]![Staff] = "New" Then"....and then I have it OpenForm to the In form. The Else portion has it open the Out form.

For some reason, this just bypasses the In form and only does the Out form.

Any help is appreciated.
Attached File(s)
Attached File  TimeSheet.zip ( 45.26K )Number of downloads: 4
 
Go to the top of the page
 
Doug Steele
post Jun 20 2019, 02:49 PM
Post#2


UtterAccess VIP
Posts: 22,184
Joined: 8-January 07
From: St. Catharines, ON (Canada)


I didn't bother downloading your attachment, but I'm guessing that the Staff field contains Null when it doesn't contain the word New. If that's the case, you can't simply use = to check its value.

--------------------
Doug Steele, Microsoft Access MVP (2000-2018)
Personal webpage
Microsoft profile
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Co-author: Effective SQL: 61 Specific Ways to Write Better SQL, published by Addison-Wesley Professional
Technical Editor: Access 2010 Bible, Access 2013 Bible, Access 2016 Bible, all published by Wiley
Technical Editor: SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, 4th Edition, published by Addison-Wesley Professional
Go to the top of the page
 
GroverParkGeorge
post Jun 20 2019, 03:30 PM
Post#3


UA Admin
Posts: 35,544
Joined: 20-June 02
From: Newcastle, WA


To be honest, I'm not a fan of moving back and forth between various forms, each of which is supposed to do one part of a process.

Here's how i would approach this. One form with a subform and toggling time in and time out fields so that you can control entries. This can, of course, be made even more responsive by checking for existing time in before allowing a time out on the same day, by verifying that a time in is earlier than the time out of that same day and so on.

Attached File  RadTimeSheet_Revised.zip ( 47.74K )Number of downloads: 2

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
wagman
post Jun 20 2019, 03:44 PM
Post#4



Posts: 250
Joined: 12-March 08



Doug,

No, actually the Staff field will either be "New" or "Old", based on whether the Date Field is empty of filled.

Thanks,
John
Go to the top of the page
 
wagman
post Jun 20 2019, 03:47 PM
Post#5



Posts: 250
Joined: 12-March 08



George,
Thanks for the reply and the work you did. I like it, but I really want something simple and not anything the staff can view or change. Simply, choose your name, click a button and done.

Thanks again.
Go to the top of the page
 
GroverParkGeorge
post Jun 20 2019, 04:59 PM
Post#6


UA Admin
Posts: 35,544
Joined: 20-June 02
From: Newcastle, WA


Even better.

Try this approach. Closer?

Attached File  RadTimeSheet_V2.zip ( 61.02K )Number of downloads: 2

--------------------
My Real Name Is George. Grover Park Consulting is where I do business.
How to Ask a Good Question
Beginning SQL Server
Go to the top of the page
 
wagman
post Jun 21 2019, 06:58 AM
Post#7



Posts: 250
Joined: 12-March 08



Thank you. That will work nicely. I was trying to just have a single button, but this just keeps it simple.

I appreciate it.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    25th August 2019 - 10:33 AM