Modules & VBA :: How To Check If A Number Is Divisible By 6
Feb 1, 2015is there a function that will let me check if a value that was input is divisible by 6?
View Repliesis there a function that will let me check if a value that was input is divisible by 6?
View RepliesI'm trying to create some code that will create a new folder depending on the ID that is currently being added to the database.What happens at the moment is a new ID is generated which in turn is job reference.When this is added to the database a folder is created with a prefix of this ID number and a 20char test specified in a text field by the user.
What I am trying to achieve is this:If the ID = 57...Then a folder is create called 1 - 500 (and ignore if one has already been created, which it should have at ID number 1)...When the ID Number 501 comes along another new folder is create called 501 - 1000 etc etc.The idea is not to have 3000+ folders in just one folder making it look a bit messy and lengthy to look through.
i want to check if the number and the date of telegram is existed
the number should be LIKE not equal
the date should be equal
this is what i wrote
Code:
If DLookup("Telegram_Number", "tbl_Violation_Of_Building", "Telegram_Number Like " + Forms!frm_Add_Violation_Building!Telegram_Number + " And Telegram_Date = #" & Format(Forms!frm_Add_Violation_Building!Telegram_Date, "yyyy/mm/dd") & "#") Then
MsgBox ("number existed")
[Code]....
The DolphinBatchNo has number data type but the following sql statement doesn't capture the ight records. it doesn't check id dolphinBatchNo is blank.
Code:
strsql="select * from `MasterTBL` where PolicyNumber>=" & TxtFPolNo & " and PolicyNumber<=" & TxtLPolNo & " and PolicyStatus='Live' and DolphinBatchNo is null order by PolicyNumber"
See attached the Workbook. I need to check the policy Numbers in Column A of all the sheets in the attached workbook if its present in Access Table. If yes then write the corresponding ScanDate and BatchNo from Access table to columns I and J of all the sheets. I need to write VBA code to perform it.
In the attached workook, only Sheet1 contains the data but in actual there will be data in 5 sheets in the workbook.
I have a Paycheck form with a subform on it. The goal is to not have to click on the check field for every paycheck, instead use a Batch procedure. When you click in the subform (field) (CCheckNo) which gets the focus by default it advances to the next check number and performs other code operations. If you have a lot of checks this is not very user friendly. I created a command button on the subform to try and auto ate this process. Below is the code for this. It gives no errors but does nothing. The db is very complex. The form opens to the first record but can't be sure when the user could run the Batch procedure.
The idea was to try and use the OnClick procedure to run the event code. The field in question is CCheckNo which advances the check number.
frmBonusReimbursementChecks is the Main form.
(Check) form is a Subform
CCheckNo field gets focus on Load which is the Subform.
Code Below is on a Command Button on the Subform.
If MsgBox("Are you sure you want to Assign All Checks?", vbYesNo, "All Checks Confirmation") = vbYes Then
End If
If IsNull(Me.CCheckDate) Then 'If no Check Date, Assign One.
Me.CCheckDate = Date
End If
If IsNull(Me.[CCheckNo]) Then 'Advance to the next available Check Number.
Me.CCheckNo = Next_Custom_Counter
[code]....
creating sequence number in a query using a starting number. For example i want to use the starting sequence number as 5
---SEQNUM---------COLOR-----------
-----5------------------blue--------------
-----6------------------red---------------
-----7------------------orange-----------
-----8------------------black-------------
Sending email using VBA & HTML. I want send email from access. Message in body contains some text and table in HTML format. I need check if email was really sent or cancelled with user.
Code:
Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
With objMail
'Set body format to HTML
[Code] ...
I need some message (for example):
If error then
MsgBox "Email not sent"
Else
MsgBox "Email sent"
End If
I have value in the form call (welder) & based on the other data i will enter in form i need VBA to check if this welder is certified to do the job or not.
View 4 Replies View RelatedI am required to write a code to check the positioning of a text in a string.
E.g.
"~[Admin]~xxxxxxxxx~ACK~" = Acknowledged
"~xxxxxxxxx~[Admin]~ACK~" = Not Acknowledged
"~xxxxxxxxx~ACK~[Admin]~" = Not Acknowledged
As you can see, as long as the string starts with "~[Admin]~", it is counted as acknowledged. If the "~[Admin]~" appears anywhere else except the start, it is counted as not acknowledged.
I know I'll have to use If-else statements and EOF to cycle through my entire column, but how do I check the positioning of "~[Admin]~"?
Are there wildcard statements that Access VBA can use similar to SQL's "*"?
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?
I'm trying to figure out how to filter a report using a check box.
I have created a form, which if you push an industry labled button on that form it will show you the report with what work was done for that industry.
Now I'm trying to modify it so that I have a group of check boxes; each check box being a different office location the company has.
What I want to make happen is if say out of office A. B. C. and D., A. and D. are checked and I hit the button of a specific industry it will bring me up a report of office A. and D. Combined for that industry.
From what I've figured I can create a bunch of reports of all the different possiblities and link those to that senerio, but that seems tedious and ridiculous.
Is there a way I can code VBA to do this for me? Or am I going to have to go through the proccess of creating a bunch of different querries and reports beyond what I have now to pull up an industry.
I have a lookup which selects a 'Recipient'.
I need to add a check to see if this 'Recipient' (user selected) already exists within another table.
If so, I need a pop-up to appear.
If not, I want the user to continue unimpeded.
In the code below I want to wait for ten seconds if there is connection to the server, if not to exit the sub with message "No connection to server". How to check it
Dim req As New XMLHTTP60
Dim resp As New DOMDocument60
Dim xmlNodeList As IXMLDOMNodeList
Dim myNode As IXMLDOMNode
Dim xmlNode As IXMLDOMNode
Dim presription As IXMLDOMNode
req.Open "GET", "https://api.zdravstvo.gov.mk/rest/prescriptions/" & Me.br_recept, False
req.send
resp.LoadXML req.responseText
I'm trying to check if a subform is visable. The following code is just test code so I can get a result. I keep getting an error on the .IsVisible section.
If datTimePlus15 <= datCurTime And [frmBarstockAreaSubForm].IsVisible Then
MsgBox datTimePlus15 & " " & datCurTime
datTimePlus15 = DateAdd("n", 1, Now)
End If
I use code to check folder as below.
If the folder not exists, then create it.
If dir(myfolder) = "" then
mkdir(myfolder)
end if
How to add code to check empty folder, like below?
If dir(myfolder) = "" then
mkdir(myfolder)
else if empty(myfolder) then //there is no empty function in access
do something
end if
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 RelatedI 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
I have an Access 2010 db which has a load of global variables of type Boolean. The values are different for each machine the database is stored on, so I have a linked table to a separate Access mdb. On startup the database opens the linked table and assigns values to each variable.
However I need to differentiate between a valuable value of False and the variable having not been set. As boolean variables default to False, this is a problem. One option is to use data type Variant, but I know this is not efficient. I am considering using data type Byte instead of Boolean, with 1 as False and 2 as True.
I am creating a few forms one of which is the MAIN FORM that closes upon opening another form.
What I am looking for is when another form closes, if no other forms are open, then open the MAIN FORM again.
Can I use this : If CurrentProject.AllForms("BUT KEEP THIS EMPTY").IsLoaded Then ???
How I can check if connection to SQL server is established with VBA before the SQL is executed. btw I use VPN connection to connect to sql server, and some times VPN connection is going down in middle of work and it is quite unconvinced.
View 2 Replies View RelatedWe have a table, JobRegister that people enter information on using a form, FrmOrderEntry
I would like to run a check when a serial number is entered in the field SerialNo to see if the same serial number exists where CompletionDate is null.
this would stop duplicate open orders being put on the system, or new orders being entered where the previous order hasn't been completed.
My application relies on whether Outlook is open and more importantly, with the correct Exchange profile selected. To ensure this I have the following code which, on the work PCs (Windows XP and Office 2003) works correctly.
Code:
If Outlook_is_Running = True Then
Set myOlApp = CreateObject("Outlook.Application", "localhost")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set colFolders = myNameSpace.Folders
On Error Resume Next
[code]....
The work PCs are being upgraded soon to Windows 7 and Office 2007 so I have taken the application home and started to develop it on my home PC (Windows 8.1 64 and Office 2013 64). I have used PtrSafe where necessary and have compiled with no errors, but this code always returns false even though Outlook 2013 is open.
On further investigation, if I comment out the 'On Error Resume Next line I get the error Active X component cannot create the object (or similar) Error 429. This is the same regardless of whether Outlook is open or not
I have button on my form that uses a selected record in a listbox (non multi-select) to run code that updates a table. The code itself works great so long as there is a record selected in the listbox. If no record is selected an error is thrown. I'd prefer the end user not to ever see that error. If the end user clicks the button and no records are selected, I'd like for nothing to happen at all. I've tried several variations of checking the listbox with an if / then statement to see if records are selected and if so to exit sub, but they all throw errors when no record is selected in the listbox.
Code:
If IsNull(Me!lstHeatTreatments) Then
Exit Sub
End If
[Code].....
I dont know if this is possible but I want to change a yes/no field from a list box.
I can load data in fine I can even loop through it to see what value each item is but, is it possible to allow a user to change a value from a list box?
If not do I have to use the Datasheet view?
I'm trying to check a directory for a folder name which has a certain string in it (RecNum)
However the fso object filesys.FolderExists does not take an argument when looking for part of a folder name on a particular path.
What I basically want to do is look in a directory for a folder with the RecNum variable as part of the folder name. if it exists open it, if not create it.
This is how far i've got:-
targetdir = targetpath & RecNum & ChannelPartner & Enduser
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FolderExists(targetdir) Then GoTo function_end
MkDir targetdir
If filesys.FolderExists(copypath) Then
filesys.CopyFolder copypath, targetdir
End If
MsgBox ("folder created")
function_end:
Shell "Explorer.exe /n,/e," & targetdir, vbNormalFocus