Modules & VBA :: Validation Two Condition

Apr 3, 2014

I have one case about validation in the form

example: I have entry in table this mention below:

No.Register | Code_machine
________________________

001 | X01
002 | X01
001 | X02
003 | X02
003 | X01
002 | X03

How to make validation for this case when I will submit the data 001 and X01, the system will be cancel and show warning message : "Data Duplicate!".and of course with this happen, the user will be know what they will submit, it have been submit into table before by other user. if I will do make with one validation like noregister as checking data and use the DLookup, this is no problem.

View Replies


ADVERTISEMENT

Validation Condition Where At Least One Of Four Fields Meets Criteria

Jul 29, 2015

Windows XP
MS Access 2007
VBA experience is very limited

So in my forms 'BeforeUpdate' property I want to validate whether a condition is met. The condition is whether 'any one of 4 fields contains something (text or number)'. I have written this code for validating a single condition and it alerts if the field is left blank. This code returns a warning message when the field is blank.

If Me.[txtObjective] & "" = "" Then
MsgBox "A 'Problem Objective' is required, please complete this field.", vbOKOnly
Me.[txtObjective].SetFocus
Cancel = True

[code]...

how to write the SetFocus part. And I dont know if this is correct anyway.

View 6 Replies View Related

Modules & VBA :: AND In Where Condition

May 21, 2014

I got this code to run correctly, which pulls records where they are not junk(can be seen at end of where condition), the only issue is that the "AND" does not turn blue. Is this a problem?

Code:
If Not IsNull(Me.txt_last_rec_id) Then
'DoCmd.SetWarnings = False
SQLText = "INSERT INTO tbl_batt_id " & _
"(record_num, bat_id, manufacture, date_code, barcode, status) " & _
"SELECT " & Me.record_num & ", bat_id , manufacture, Date_Code, barcode, Status " & _
"FROM tbl_batt_id " & _
"WHERE record_num = " & Me.txt_last_rec_id & " And [Status] <> 'Junk'"

[code]....

View 3 Replies View Related

Modules & VBA :: How To Convert Where Condition

Dec 15, 2013

Everything I have goggled and tried doesnt work How do I convert the where condition to VBA

Code:
Form name frmMap
View form
Filter name
Where condition [chid]=[forms]![frmCurchesAll]![chid]

View 12 Replies View Related

Modules & VBA :: Label ID - Set If Condition In Query

Oct 24, 2013

Is it possible to set any label id as query parameter in sql code or access?

View 5 Replies View Related

Modules & VBA :: Dlookup With Multiple Condition

Apr 8, 2015

I Have one main form in access 2003 i want to use Dlookup function to 1 text box with 2 criteria is it possible?

My Formula:

Text67. Value = DLookup("Balance", "dbo_WbookEdit", "[Lotno] = '" & Forms![Edit]![LotNo] & "'" And " & [Description] = '" & Forms![Edit]![Description] & "'")

View 6 Replies View Related

Modules & VBA :: How To Send Email Automatically When Condition Met

Aug 13, 2014

I have inventory database, in database there is "NextScheduledMaintenance" field.

I want access to send email automatically when scheduled maintenance date due.

View 7 Replies View Related

Modules & VBA :: Read Through Recordset And Check For A Condition

Jun 25, 2014

Heres what I need to do.

--> open a recordset

--> read through the records

--> check to see if two fields matches e.g (qty=qty_completed)

--> if all records in recordset meets the above condition then run update statement

I want to put this code inside Form_Close. The code that I'm using checks the two fields for the condition and runs the update statement if condition is met. Problem is this a continuous form and I want all records need to meet the condition before it execute update statement.

Using Access 2010 btw.

View 8 Replies View Related

Modules & VBA :: How To Validate Three Condition Before Providing Error Msg

Feb 11, 2014

I am trying to write following code, I want Msg to pop, when all three condition are true, but it not working

'''Non Budgeted Projects need Explanation and Variance class"

If Me.ID.Value >= 90000 And and Me.Variance_Class = "" and Me.Comments_Explanation_Delta_____100K = "" Then

MsgBox "This project is Unbudgeted. Please Add 'Variance Class' and provide Explanation why this project is Unbudgeted project has been added.", vbExclamation, "Rules Checker..."
CheckRules = False
GoTo Exit_CheckRules

View 14 Replies View Related

Modules & VBA :: Data Append From Excel With Condition?

Feb 11, 2015

I am trying to append some data from an excel sheet. Following code used for same and successful. However, i need to put few condition while importing the data to the Access table. i.e;

Table : tblMain
Filed : Vessel, Voyage, contianerNo, ......, ......, .....,

while importing, need to check whrt "containerNo" which is importing already in the table under the particular voyage. If yes error msg should pop up warning that the particular container is already exists. If same container number is already exists in the same table under a different voyage, data should be imported without any error.

Code

Private Sub Command0_Click()
Dim Filepath As String
Filepath = "D:Xxxx bl_Impts_main.xlsx"
If FileExist(Filepath) Then
DoCmd.TransferSpreadsheet acImport, , "MainImportsfromxls", Filepath, True

[Code] .....

Code Source : [URL]

View 6 Replies View Related

Modules & VBA :: How To Open Report From Msgbox With A Condition

Jan 13, 2014

i have a form to enter a new client if the client is existed then a message box appear and tell me that this client is existed and his number id is ## with two buttons yes and no.if i click yes i should go to a report that contains information about that user and this report take his data from a query

new client save code
---------------------
Dim MSG As Integer
Dim ExistentID As Long
ExistentID = Nz(DLookup("P_ID", "tbl_Personal_Information", "Full_Name = Forms!frm_New_Person!F_N"), 0)
If ExistentID > 0 Then

[code]....

when i click yes the report should open with the existent id but he open a input box to ente an id and his title is tbl_personal_information.PID it's the ID field that it's named P_ID in the query

View 4 Replies View Related

Modules & VBA :: Subform Checkbox Used As Condition To Update Records

Aug 26, 2013

My subform consists of a list of tasks that are waiting to be verified. in order to verify tasks, the user scrolls through the list of tasks and checks a checkbox (discrepancyverified) on each record they wish to verify. After the user has finished checking all the records they wish to verify, they click a verify button on the main form which should then go back through each record and update the verifieddate value of any that are checked to today.

This is what I have so far:

Code:

Private Sub Command19_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim ctl As Control
Dim varItem As Variant

[code]...

View 3 Replies View Related

Modules & VBA :: Error When Apply Condition Formats On Excel Sheet (from Access)

Oct 14, 2014

I am pushing some data to Excel from an Access query. When the data is in Excel I reformat the sheet by changing the fonts, applying borders and cell formats - I have got all of this to work fine.

The one thing I am struggling with is applying conditional formats. I am pretty sure it is something to do with incorrectly referencing the applcation/sheet. An extract of what i think to be the key parts of the code are below.

....
Dim ApXL As Object
Dim xlWBk As Object
Dim xlWSh As Object
...

Set ApXL = CreateObject("Excel.Application")
Set xlWBk = ApXL.Workbooks.Add
ApXL.Visible = True

[Code] ....

View 8 Replies View Related

Modules & VBA :: Add Validation For Not Zero

Jul 24, 2014

I have the following that I found in a post on Keypress of a text field to limit the field to only numbers. This works great only I need to disallow the entry of zero.

If KeyAscii <> 8 Then ' Not Backspace (important for error correction)
If KeyAscii < 48 Or KeyAscii > 57 Then 'Not a number
Beep 'Let the user know they hit an illegal key
KeyAscii = 0 'Don't let the keystroke through
End If
End If

View 14 Replies View Related

Modules & VBA :: SQL Postcode Validation

Jul 10, 2015

I've tried to steal an SQL Postcode validator (This is for UK postcodes) and add it to an AfterUpdate event on a field in MS Access. It doesn't work, obviously,The VBA code is:

Private Sub Postal_Code_AfterUpdate()
Dim CHECK_Code As Integer
Dim LResponse As Integer
If InStr("[A-Z][0-9] [0-9][A-Z][A-Z]", Postal_Code) = 0 Then
CHECK_Code = 0

[code]....

Also, how would I put the Check_Code value into the Message box to see what it's bringing back?

View 8 Replies View Related

Modules & VBA :: Form Data Validation?

Jun 12, 2013

I would like to write some code to validate that when a user enters data into a text field, the user must enter 4 digits.

View 3 Replies View Related

Modules & VBA :: Validation Check Against Another Table

Jul 26, 2013

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.

View 8 Replies View Related

Modules & VBA :: Data Validation With Comboboxes

Jan 23, 2015

I have 2 combo boxes on a form. The 2nd box is not visible unless the 1st box is set to a specific value (Illness). Once the specific value is set, the 2nd box appears with appropriate data for selection.

Goal #1:
I would like to have the form checked before it is closed to ensure that if the condition in box 1 is "Illness" then the 2nd box must have a value and can not be null.

Goal #2:
I am also having problems with the 2nd combo being visible when form opens or becomes current. The field is set to visible=false normally but needs to be visible when form opens if the conditions mentioned above are meet (true).

Private Sub Form_Unload()
If IsNull(Me.Incident_Classification) Then
MsgBox "Please select a type of Illness"
Me.Incident_Classification.SetFocus

]Code] .....

View 3 Replies View Related

Modules & VBA :: Enable Button With Validation Rule

Apr 5, 2014

I have a button on a form that when I press it, I want it to validate a user's Windows Login ID in a text box on the current form against a table before allowing them access to a form.

If the Login ID in the text box does not match any value in the table I have defined, I wanted a MsgBox displayed saying invalid credentials. Of course if the ID exists in the table, I'd like it to open the next form.

View 4 Replies View Related

Modules & VBA :: Run Validation In Order In Unordered List

Jan 12, 2014

How to define Order that starts with a dependency on the existing value.

Basically, a function that chooses what Status Validation to run then knows when to stop that displays some very simple predictive Inference.

Each Record has a Status. The Status will generally be correct 85% of the time. Once in a while, various things in the database are updated that triggers the business need to change the status.

-A collection of Rule based validation functions matches each Status.
-The objective is not to run Rule 1 through 40 sequentially for each record.
-Each Rule Validation function is lengthy and can take 0.1 seconds per rule (per record).
-If the current record's rule is still valid 85% of the time, Then run that Status Rule Validation function first.
-If the Validation returns True, there is no need to run the rest of the rules. Move to the next record.

The challenge: Statistically, if the Current Status failes its Rule Validation, there is a high probability that one of the Status Validation Function near to the current Status will validate to true.

Like the board game Clue, once a Validation Rule comes out False, there is no need to check it for that single record again.

In an extremely simplistic world, think about Status of : Order in Progress, Order Completed, Completed Order Paid, Shipping in Progress, Item Shipped Ready, Shipped, In Transit, Delivered, Rejected, Payment Recended, ...

So, if the current status was In Transit, there is a higher odd that Delivered would be the next. There would be no need to start from the beginning again. The wonderful world of Metadata.

View 2 Replies View Related

Modules & VBA :: Error Trapping For Data Validation

Feb 15, 2015

I am using following routine to lift data from Excel files into Access tables. Whole thing works, well, most of the time. The only issue I have is the spreadsheets are received from warehouses and even though they have been given strict instruction to stick to the template, I have had to adjust the spreadsheets. Amongst errors I get are:

Field 'F16' does not exist in table 'SA1'. (In this case I simply delete the last most empty column to fix this).

Or there are column name spellings and in such cases, I get no error and the simply code hangs.

Is there any routine that I could incorporate in the code that clearly states what issues are being experienced. This way I can pass the db to the user to run it themselves.

'Dim dbs As Database, tdf As TableDef
Set dbs = CurrentDb
On Error GoTo Macro1_Err
DoCmd.SetWarnings False
' RunSQL executes a SQL string

[Code] .....

View 7 Replies View Related

Modules & VBA :: Skipping Controls On Validation Check Before Update

Oct 8, 2013

I'm working on a code that checks all blank/null text fields and combo boxes in a form and notifies the user if a field is not filled. The code below works if all fields are required, but I can't use it on forms that have fields that are not really mandatory. I've read somewhere on the net to use tags on the controls i want to skip checking, but that's where i get lost.

Code:
Dim stdResponse As Variant
Dim ctl As Control
' Enumerate Controls collection.
For Each ctl In Me.Controls
' Check to see if control is text box

[Code] .....

View 8 Replies View Related

Modules & VBA :: Adding Extra Validation In Sample Database

Aug 20, 2015

I am trying to add extra validation in a sample db (done in A97 (converted to A2003)see attached.

I am attempting the following: Please not that the db has existing validation which I would like to keep (or change if advised) ...

Conditions:
1. Input into field "ID" must start with the letter P or p or R or r
2. If field "ID" starts with the letter P or p and field "Code" starts with the letter R or r, then a message stating that this combination is invalid should appear
3. If field "ID" starts with the letter R or r and field "Code" starts with the letter P or p, then a message stating that this combination is invalid should appear.

View 3 Replies View Related

Modules & VBA :: New Record Validation - Insert Date Only If ID Is Not Null

Oct 2, 2014

If a new record is created, insert date only if customerID is not null

Private Sub Form_Current()
If "CustomerID", "TblDietPlan" = <> 0 Then
If Me.NewRecord Then Me.MealDate = DMax("MealDate", "TblDietPlan")
End Sub

View 1 Replies View Related

Modules & VBA :: 4 Unbound Controls Require Data - Validation Event Triggers Without Command Button

Aug 13, 2015

There are 4 unbound dropdown list box that will have a default value of empty string. All 4 must have values entered (data is required).Once all 4 are required - the bottom 5 text box will become enabled (optional data).Forcing the user to click on a Validation Button

Some users type then use the mouse to select the next.Other users type to select then tab.The trick is: After filling in the 4th listbox and validating all 4 have values, the event must trigger code to enable the 5 optional text boxes below.This provides a seamless data entry environment.

I have been doing this in other places, but the transisition after the last required field is complete gets ugly.If Trim(cmbBoxname1 & "") = vbNullString ' check all 4..If it is the 4th one, the event seems not to happen quick enough for the bottom 5 text boxes to be enabled so the user can continue with data entry.

View 9 Replies View Related

An SQL Str Using IF Condition

Sep 19, 2005

Good morning


I am hoping some one can help me out with an SQL string I am having problems during to get working.

This is my code

Private Sub SearchRoleSeeking()

Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Dim strFilterSQL As String
Dim txtBoxValue As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qrySearch")

lstSearchResults = txtSearch1

If Me.txtSearch1.Value = "Temp" Then
txtBoxValue = 1
End If
If Me.txtSearch1.Value = "Perm" Then
txtBoxValue = 2
End If
If Me.txtSearch1.Value = "Temp or Perm" Then
txtBoxValue = 3
End If
strSQL = "SELECT tblPersonalInformation.[PersonalID],tblPersonalInformation.[Surname],tblPersonalInformation.[Forename],tblPersonalInformation.[DOB],tblPersonalInformation.[WantedRate],tblPersonalInformation.[WantedSalary],tblPersonalInformation.[Status],tblPersonalInformation.[RoleSeeking]" & _
"FROM tblPersonalInformation " & _
"WHERE tblPersonalInformation.RoleSeeking = ('txtboxvalue')"


qdf.SQL = strSQL
Me.lstSearchResults.RowSource = "qrysearch"

Set qdf = Nothing
Set db = Nothing

End Sub


let me try explain what I am trying to do.
I have a form where personal information is entered into. It has an option group that allows 3 choices.
I have made a form that I will use to search (the above code is from that.) What I am trying to do is if a person enters "Temp" into txtSearch1 then for the SQL statement to search "tblPersonalInformation.[RoleSeeking]" for the value 1.
If a person enters "PERM then for the statement to use 2 as the value for txtSearch1 and so on.

Can anyone help out with my task at hand.

Thanks everyone for your help.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved