Modules & VBA :: Restrict Date If Already Exists
Feb 5, 2014
I have a main form which employees use to report their bi-weekly time. The main form is automatically assigned a [RecordID] and the employee must select their [Profile] from a combo box. This main form contains (2) sub-forms. Both sub-forms use the same data source table.The first sub-form is visible in the body of the main form and linked by the [RecordID] and employee [Profile]. The employee enters each date worked and hours for the reporting period.
The second sub-form is hidden and linked to the main form by the employee [Profile], basically keeping a running ledger of all the dates and hours reported by the employee. What I would like to do is have a message box appear if the employee mistakenly enters date that has already been reported.
View Replies
ADVERTISEMENT
Mar 13, 2015
I have the below script:
For Each Item In offexchfldr.Items.Restrict("[SenderName] = '" & frmfm & "'") ' Select Items that match Sender Name on form
If Item.TaskSubject = subid Then
Item.Categories = frmcat ' Update category from form to outlook
Item.Save
End If
Next
This script checks every item in the outlook inbox where the item.SenderName = my database sendername
This works every time except for when the sendername has quotes or single quotes in their name. So i am trying to utlize the replace method on the item sendername before trying to find the items in the inbox but its not working.
Below is my attempt that does not work.
For Each Item In offexchfldr.Items.Restrict("Replace([SenderName],',"") = '" & frmfm & "'") ' Select Items that match Sender Name on form
View 2 Replies
View Related
May 6, 2015
I created a database which when macros are enabled the only thing visible on the screen is the forum. All tables as well as the ribbon bar is disabled. I also disabled right-clicking.
My issue is, for those who do not have macro's enabled, it opens up in design view and allows access to the left-hand tables until the user clicks the trust button at the top. Once trust is clicked, everything hides as expected.Is there a way to restrict access if they do not have their macros enabled?
View 1 Replies
View Related
Feb 10, 2014
I've been asked to make sure only certain users in my database are able to print anything (i.e. Administrators). Is there any option/property to do this?
I have already built in User Access controls using the ctl.Tag property. The only way I can think off the top of my head is when a 'general user' uses it, to ensure that every control is displayed 'on screen only'. This of course doesn't stop them printing - just makes them print blank pages!
View 12 Replies
View Related
Jan 2, 2014
I have created a form which enbles users to enter data into the fields which will add a new record to my table. What I am trying to do now is to create some kind of validation rule that will check whether the record already exists.
I need it to work this way; there are four input fields- 3 text and 1 is a date filed. When the user enters a new record they are not allowed to create a record that conatins the same combination of values. So if one record has for example filed 1 = 1 field 2 = abc field 3 = def; then no other record can have the same combination of values.
If the user enters an already existing combination there would be an error message saying which field is incorrect. If the combination doesn't exist it would add the record and display a message that the record was successfully added.
How can I do this?
View 11 Replies
View Related
Nov 24, 2014
I have an application that I have automatically checking to see if tables are valid and connected, etc. If the app finds that the tables aren't connected or aren't working, it automatically tries to re-connect those tables in the background without the user's knowledge. The time I'm having trouble is if the SQL Server doesn't exists (the back-end tables are on a SQL Server). I would like to check to see if the SQL Server exists before I try to re-connect tables so that no SQL Errors pop up but I'm not sure how to figure that out with VBA.
View 3 Replies
View Related
Sep 10, 2014
I have a form, which has a combo box which a user can select an employee - the combo has three columns (Employee_Number, Surname, Initials) although the Employee_Number column is set at a 0 width, so not visible.
The form is bound to a query which only shows records that are 'Active'
When a user selects and employee in the combo box, I want the AfterUpdate event to check and see if there is already an active record - if there is, throw up an error message and then reveal a couple of buttons giving choices what to do next; if there isn't an active record, reveal three textboxes and then populate those textboxes with the values from the three columns from the combo.
The bit that is sticking me is the search - - I have tried DCount, but can't seem to get it to work
Here is the section of code that I am battling with:
Code:
Dim EmpNo As String
EmpNo = cboEmp_Check.column(0)
If DCount("Employee_Number", "Incomplete_Training", "Employee_Number=" & EmpNo) > 0 Then
MsgBox "Existing", vbOKOnly
View 9 Replies
View Related
Aug 22, 2014
I'm trying to use DCOUNT to check to see if a date exists and if it does then i can cancel the input. The code im using is as follows however its returning datatype mismatch.
Code:
If DCount("[pick_date]", "tblPicker_Stats", "[pick_date] = '" & txtPickDate & "'") > 0 Then
MsgBox "Statistics for this date already exist", vbOKOnly, "Error"
End
End If
View 7 Replies
View Related
Aug 22, 2013
I currently need a way to check to see if a a field already exists. To be exact I have an access application that imports data from multiple sources and saves the file name of these imports into an import tracker table. The table has four fields, file name, Date Imported, Import Type, and Number of Records. I am writing some code that checks a Boolean given by a form. If the Boolean is true It skips over checking.
If it is false It needs to check my import tracker file names to see if the file was already imported. If it was then it will skip over the file and the algorithm will check the next file given by an array. So I was wondering..How would I go about making it check if the file already exists in the table. I was thinking of turning the File Name Field into a primary key, since there will only ever be one File Name of every type.
View 4 Replies
View Related
Oct 30, 2014
I'm trying to view a pdf in a form if the file exists. My search has brought me to trying the WebBrowser control. I have it loading the file but it launches Adobe instead of just showing the PDF in the window on the form.
View 13 Replies
View Related
Dec 15, 2014
How to search for a file using the dir function, however, i need to search for a file from a main folder which may have several sub folders.
I am having no luck so far - i understand there is a recursive search facility but im not sure how i can get this to work with what i am trying to achieve.
This is the code i have for the dir function:
If Len(Dir("as-tamworth-50midlands.qa$TamworthLaminate C of CsCircuit Foil" & CofC & ".")) = 0 Then
MsgBox "This file does not exist"
Else
MsgBox "Yippee"
End If
View 5 Replies
View Related
Jul 14, 2014
I can already send emails out as PDF files when an email address exists, however, I'm trying to validate whether or not an email address does actually exist. My problem is, there are four possible locations where an email address could be: MainEmail or Contact1Email or Contact2Email or Email (the last one - Email - is in a separate table).
Four text boxes exist on the form that is being actioned (the form is based on a query to extract the relevant information) and are available to test for an email address being present. What I'm struggling with is ensuring that the 'To' box in Outlook always gets populated or Outlook chucks a hissy fit. I have been trying various IF Then Else and Do Loop plus a myriad of other ways but none are reliable, especially if no email address is present which can be the case.
View 14 Replies
View Related
Nov 4, 2013
I have code working for some workers here ,who used to save excel files in a folder and my databse upload those files into database and then do the rest.I am looking for a code in vba which,on upload button matches the file in table and if the file already exists ,it should not upload again in the table and if it does not exists it should upload . I have attached my code below :
Private Sub Command0_Click()
Dim strcPath As String
strcPath = "O:QA FilesQC ReportingPending Review"
Dim strcNewPath As String
strcNewPath = "O:QA FilesQC ReportingMovedFiles" & Format(Now, "yyyy-mm-dd h-mm-ss") _
& " Excel Files" & ""
[Code] .....
View 1 Replies
View Related
Jul 17, 2014
I am trying to check if a record exists, but I keep getting a error!!!
Private Sub Command10_Click()
If DCount("*", "tbl", "[ID] = "") <> 0 Then
MsgBox "This record already exists.
Else
stDocName1 = "McrAddNewRecord"
DoCmd.RunMacro stDocName1
End If
End Sub
View 5 Replies
View Related
Sep 8, 2014
I have a module that I am using to verify that file paths in my table point to valid jpg files. The table has grown quite a bit since I first created the module and it has gotten to the point where it's taking too long for the module to execute. I'm in the process of trying to change the record set for the module from the table to a stored query procedure but it's turning out to be a little tricky for me. When I execute the following module, I'm not getting any error code, it just doesn't seem to do anything at all. The bits in red are the parts I've changed. Before that the module executed as I expected it would.
Code:
Sub TestIt2()
Dim strFileName As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("QryUpdateRevisionHistory")
[code]....
View 1 Replies
View Related
Nov 25, 2014
I am storing values of pictures and the location of them in a table, this works fine!... using OpenRecordset. The problem is that when the function is called to store the information, it just keeps adding the same values of each file in the folder over and over again in a word "Duplicating" the information.
I have tried various methods using the OpenRecordset, but cannot seem to find the correct manor of applying the code.
Below is the function I have for storing the data...
Code:
Public Sub GetFilesNamesFromFolder(strFolderPath As String)
On Error GoTo ErrorHandler
Dim objFSO As Scripting.FileSystemObject
Dim objFolder As Scripting.folder
Dim objFile As Scripting.File
[Code] .....
View 12 Replies
View Related
Aug 19, 2013
Actually what I am looking to do is have an Access application check some Web site for the presence of a number. This number could be the Serial number of the application and if this number exists to maybe show a message in the aplication or even terminate the application.
A quick and dirty way is for User Serial number 254, to put on a specific page of a Web site say arbitrary file 254.jpg (invisible on the Web site). The application would check for the existence of this file and if it is there, it could take some action. Everything would have to be done in stealth mode.
The following code can tell me if a specific URL exists, in this case [URL]
Code:
Private Sub cmdArbitray_Click()
Dim blnDum As Boolean
blnDum = blnCheckURL("http://www.VisualDentist.com")
' If blnDum = True then it exists
End Sub
Public Function blnCheckURL(ByVal strURL As String) As Boolean
Const FLAG_ICC_FORCE_CONNECTION As Long = &H1
blnCheckURL = (InternetCheckConnection(strURL, FLAG_ICC_FORCE_CONNECTION, 0&) <> 0&)
End Function
1) How can I check for file 254.jpg?
View 1 Replies
View Related
Mar 14, 2014
I am trying to achieve the following - I want to query a table to see if a record exists with a particular field blank. If so, I would like to prompt the user for data.
In real world terms, when assigning an item to a user I would like to first make sure that the item is not already assigned to somebody else. I have 4 fields, UserName, Item, IssueFrom, IssueTo. So when an item is assigned to a user, the first 3 fields are populated and the IssueTo remains blank, until that item is assigned to somebody else.
At the minute I have nothing in place to prevent a user from assigning the same item to multiple users and having multiple records for the same item in the table.
View 7 Replies
View Related
May 27, 2014
I have a table in Access that I have a form saving new records to. Before this save occurs, I would like Access to check if the account number already exists and if the account does exist if it is outstanding. If both of those conditions are met I would like a message box to display and cancel the save as it is a duplicate. I can't seem to get it to work though.
I was thinking to use a filtered recordset based on one of the conditions and then perform a find on that recordset to see if it is null.
Code:
dim acct as long
dim rstfiltered as DAO.Recordset
Set rstfiltered = CurrentDb.OpenRecordset("SELECT * FROM tblclstrack WHERE [Request Status] <> 'Completed'")
acct = Me.cd_number.Value
[code]...
View 9 Replies
View Related
Feb 2, 2014
I have a database that has 2 tables. Table A and Table B. Table A is my primary table. On this table I have 2 fields. The first field is a LOOKUP Field that looks up information from Table B and displays my selection in the field on Table A. Then using DLOOKUP I automatically input the information in the Second Field on Table A based upon the selection from the First Field.
This is working mostly correctly. However, the problem is, when I click on the next record in the table, it automatically changes the Second Field on that record to the same value as the record before it and continues this trend each time I click on another record. This occurs without me making a selection in the first field. If I make a selection in the first field it does change the Second Field to the Correct Value, but then the next Record has the same issue.
How do I go about fixing this so it doesn't change the value with the change of the record. Only change if I change that particular field within that 1 record?is there a way to restrict the Value's in my lookup field to only include the Values from Table B that aren't already in Table A?
View 5 Replies
View Related
Dec 23, 2004
Hi guys...got a problem here....
I got a query which joins two table....
Individual
fid1
fQSname
fQSRegno
Point
fid2
fQSRegno
fQSPoint
Tables join using fQSRegno.
Scenario is
Tbl Individual contains all the members info.Tbl Point contains point given to members who attend courses. Problem is when I created a query...
Query1
fid3
fQSname
fQSRegno *from tblPoint
fQSPoint
the data shows only members who got points. Is it possible to include member who don't have point like new registred member to show in this query....
TQ
View 1 Replies
View Related
Oct 24, 2013
I'm trying to get my "IncidentDate" field to autopopulate two other date fields to a few days from the "IncidentDate". The other two date fields are "ContainDueDate" and "RootDueDate". I'm trying to accomplish this on my "Test CAP Form"
I tried using the following in the BeforeUpdate of "ContainDueDate" and received a complier error: expected =
Code : DateAdd(d,2,[IncidentDate])
so I removed the parenthesis and nothing happened
Code : DateAdd d,2,[IncidentDate]
I even tried redoing it in the AfterUpdate of "IncidentDate" and nothing happened either
Code : DateAdd d,2,[ContainDueDate]
I'm not sure if I'm even using the right function to get what I want.
View 4 Replies
View Related
Nov 15, 2005
I have a database that I want to install on a client's pc as a demo only. I want to restrict the number of records he can enter to 3. Is this possible in access? I will appreciate any help. Thx!
View 2 Replies
View Related
Feb 27, 2008
Is there any way for me to have a button on my frontpage visible to only people i name
e.g.
if user = john smith or user = fred bloggs then show the button if not do not display it.?
Being a novice step by step idiot proof help would be appreciated
TIA
View 4 Replies
View Related
Jun 26, 2005
hi all
i have created a form to enter details into a 'job' table.
here is the part of the form my question deals with.
FIELD- Airport DATATYPE- Yes/No
FIELD- Terminal DATATYPE - Lookup wizard (the values 1-5 stored in a separate terminal table)
basically the system involves entering minicab jobs into the database.
the job may or may not be at the airport.
THE RESTRICTION I WANT TO PLACE ON THE JOB FORM/TABLE
if the airport checkbox is ticked (Yes), then the terminal value can be set (1-5) from the form.
if the airport checkbox is unticked (No), then the terminal value cannot be changed from the form.
if this can be done, how can it be done? anyone..??
View 14 Replies
View Related
Aug 23, 2006
I have impletemented a user system for my database with different access levels relating to entering and editing data.
I would like to make certain forms only accessible to a specific group of users. Is this possible and how?
Thanks,
Gary
View 1 Replies
View Related