Forms :: Force Unique Set Length Field Value OR Exceptions

May 2, 2014

Is there any way to force a field value to be unique and of a set length, but with exceptions?

Let me explain... I have a text field in my table called "employee_number" and this value is always one of the following:

NULL
an 8-digit number
the word "External"

What I want to do is to force that field to either be NULL, the word "External", or a unique 8-digit number.

Is this possible? Obviously I can't set the source field in SQL to accept unique values only but I wondered if there was any way around it at form level?

View Replies


ADVERTISEMENT

Forms :: Force Update Of Field Before Record Is Saved

Aug 1, 2013

How can I force a field in a form to be updated before the record is saved / changed?

For instance I have a form with information on it and I want to ensure that any time the form is updated the user fills in a section providing the date and by who it has been updated by. I dont want the record to save unless that information has been filled out, and I also want it to take you to the field if you press save and it hasnt been filled out along with an error message.

To try and be a bit clearer. At current I have a Save and New button. This saves the form if dirty and opens a new record.

I want to add in the step that if record has been changed and FieldA has not just been updated then go to fieldA (Showing a message box). If FieldA has just been updated then save record and open new as normal.

My current save & new button properties are as follows (in Macro Editor)

On error Go To Next
If [form].[dirty]
RunMenuCommand Command SaveRecord
End If
If [MacroError].[Number}< >0
Message =[MacroError].[Description]
Beep Yes
Type None
Stop macro
On Error
Go To Fail
Go To Record
Record New
Go To Control
Control name Resort Code

View 3 Replies View Related

Forms :: Changing Format Of Field Based On String Length

Jun 11, 2014

I have a continuous form that displays data from a table. What I am trying to accomplish is to change the format of the field if the string length is equal to 11, to "@@@-@@@-@@@@-@". Otherwise if it is greater or less than 11 then no format.

I have tried it using code:

If Len(Me.FormFieldName)=11 Then
Me.FormFieldName.Format = "@@@-@@@-@@@@-@"
End If

Is it even possible and if so is my syntax correct or am I way off base?

View 8 Replies View Related

Forms :: Field Doesn't Show Full Length Of Record

Dec 4, 2013

My form which is based on a table carrying same name doesn't append the full length of the text to one of the fields.

I don't know where the mistake is occurring or indeed I don't know if the error is in the table or in the form.

The form is showing full length of the text but when I look it in the table, it has just one or two bits of the full length.

View 4 Replies View Related

Force Entry Of Certain Characters In Text Field?

Jun 7, 2007

Hi,

I have a DB where I want text entry of the primary key to adhere to a certain format.
I'm already using a mask of >LL000000 to force two capital letter and 6 numbers.
Is there any way I can force extra restrictions, by making for example the first 3 characters to have to be AB1, thus making every entry follow format:
AB1<number><number><number><number><number>

(FYI: Access 2003)

View 1 Replies View Related

Force Update Into Unbounded Comments Field

Oct 24, 2005

Hopefully there's someone who can help me with this!!! I've had several unsuccesfull attempts and don't know what else to try...

We're trying to force users to make entries in a field called txtComments in the frmQuestionnaire form if they provide negative responses and to stay on that record until the comments are changed. Inside the form is an option group (fraResponses) which contains options (OptA, OptB..etc.) valued from 1 through 7, based on a likert 7 scale. We're only using a likert 6 scale, so the respondents will only see 2-7 on the form. If they options B-D (valued 2-4), they are considered negative, so we want to make sure they enter a comment.

I tried to enter the italicized code under the form on BeforeUpdate, AfterUpdate, CmdUp (click to next question) and CmdDown (click to previous question), with frmQuestionnaire but nothing happens:

There is a module called clsUser which contains the following and where I tried to insert the code:

Set myForm = Forms!frmQuestionnaire
' ================================================== ==
' First, set the value of the variables
' ================================================== ==
lngQuestion = arrQ(lngArray, 0)
lngSession = GetCustomInfo("TestSession")
lngUser = UserID
lngBillet = BilletID

strComment = Nz(myForm.txtComment, "")

strComment = "None"

'If user selects negative responses
If Form_frmQuestionnaire.fraResponses.OptionValue = 2 Or 3 Or 4 And strComment = "None" Then
MsgBox "Please explain the problems you encountered with the system which " & _
"caused you to select an unfavorable response."
Form_frmQuestionnaire.txtComment.SetFocus

End If

lngResponse = myForm.fraResponses


When I place the code there, the dialog box appears for all values and goes to the next record. This is what appears for the CmdUp (click to next question):

If cUser.blnDirty = False And Me.fraResponses = 153 (this is default value for the entire option group) And cUser.blnNew = True Then
cUser.blnDirty = True
End If

cUser.CaptureAnswer
If cUser.lngArray < cUser.UBound_ArrQ() Then
cUser.lngArray = cUser.lngArray + 1
Else
cUser.lngArray = cUser.UBound_ArrQ()
End If
cUser.FillQuestions
cUser.blnDirty = False

I've tried to enter the line of code with the form and the module, but no luck.

I also want it to remain on the same record until the field is changed. The form is unbound and has the following:

Public Sub FillQuestions()


'************************************************* ****
' Purpose: Scroll through the questions
'
' Assumptions: N/A
'
' Effects: N/A
'
' Inputs:
' None
'
' Returns:
' None
'************************************************* ****

Dim lngRG As Long

Set myForm = Forms!frmQuestionnaire
myForm.txtQuestion = arrQ(lngArray, 1)
lngRG = arrQ(lngArray, 2)
myForm.prgProgress.Value = lngArray + 1
myForm.lblProgText.Caption = "Question " & (lngArray + 1) & " of " & lngQuestions
myForm.lblTS.Caption = "Test Session: " & arrQ(lngArray, 3)
myForm.lblQID.Caption = "Question ID: " & arrQ(lngArray, 0)

GetResponseSet lngRG
FillAnswers
If lngArray = 0 Then
myForm.txtComment.SetFocus
myForm.cmdDown.Enabled = False
Else
myForm.cmdDown.Enabled = True
End If

If lngArray >= UBound(arrQ) Then
myForm.txtComment.SetFocus
myForm.cmdUp.Enabled = False
Else
myForm.cmdUp.Enabled = True
End If
End Sub

Public Sub FillAnswers()
'************************************************* ****
' Purpose: Fill out the user's previous responses
'
' Assumptions: N/A
'
' Effects: N/A
'
' Inputs:
' None
'
' Returns:
' None
'************************************************* ****

Dim strSQL As String
Dim recAnswer As New ADODB.Recordset

Set myForm = Forms!frmQuestionnaire
strSQL = "SELECT datResponse.reDatQuestionID, datResponse.reDatRespondentID, "
strSQL = strSQL & "datResponse.reDatResponseSetID, datResponse.reComment "
strSQL = strSQL & "FROM datResponse "
strSQL = strSQL & "WHERE datResponse.reDatQuestionID=" & arrQ(lngArray, 0)
strSQL = strSQL & "AND datResponse.reDatRespondentID=" & UserID

recAnswer.Open strSQL, CurrentProject.Connection, adOpenForwardOnly, adLockOptimistic

If Not recAnswer.EOF Then
myForm.fraResponses = recAnswer!reDatResponseSetID
myForm.txtComment = recAnswer!reComment
blnNew = False
Else
If myForm.fraResponses <> 152 Then
myForm.fraResponses = 153
myForm.txtComment = ""
blnNew = True
End If
End If

recAnswer.Close
Set recAnswer = Nothing

End Sub

Thanks in advance for your help!!

View 1 Replies View Related

Modules & VBA :: Editing To Force At Least One Space In The Field

Jul 10, 2013

Not = " " And InStr(1,"seat_person"," ") <> 0

I have a field into which I wish to place a person's name and I want to ensure that the field has a space in it but is not a blank field,

so
all blank - illegal
"Bob" - Illegal
"Bob Smith" - legal

the edit at the top is my attempt to code it but it isn't working.

View 13 Replies View Related

Generalities And Exceptions, Or Repetitive Data?

Oct 11, 2005

Hoping for some assurance and assistance....

I am needing a database that will help to manage employee leave (holiday) requests. I have one but the current design is a bit...... well, you know.

Leave Limits are (presently) applied by one table:-
tblLimit
-------
payWeek
workType (twentysix work types some common to all sites, some apply only to one or two sites)
LimitSiteA (three sites)
LimitSiteB
LimitSiteC
LimitAllSites

So, several "faults" are immediately apparent:

LimitAllSites is ALWAYS the sum of LimitSiteA+LimitSiteB+LimitSiteC so
clearly shouldn't be there, and I don't even want to talk about that....

Also , no primary key, repeating columns... uh-oh!
Therfore....
tblLimit
-------
limitID (PK)
payWeek (date/time - always a Wednesday, our payWeek begins on a Wednesday)
workTypeID (FK to new table tblWorkType)
siteID (FK to new table tblSite)
Limit (integer)


However....with just a brief investigation, it transpires that of the 1600+ rows in this (current version) table, there are only 69 unique sets of limits (ran a Unique Values query, excluding the PayWeek).

So, what I do want to talk about is not having to add in a table row for each WorkType for each PayWeek (for each site- with the improved design). I want to apply a general set of limits, with effectiveFrom and effectiveTo dates, per Site/workType combination, which should automatically populate out 80 weeks into the future (historical records are not required - it is just to help plan future leave) and then cater for the exceptions by "adjusting" the general limits in one of two ways:
1) every day over a date range (e.g. every day between 15NOV05 and 15DEC05, decrease the limit for worktype Z in Site A by 10 percent of the BASE* limit).
2) every nominated weekday over a date range (e.g. every Friday in December 2005, increase the limit for worktype Z in Site A by 20 percent of the BASE limit).

*the two adjustment types need to be independent, overlappable, and have a cumulative effect.

e.g. for the above, if the general limit for type Z of site A were 100
14 NOV --> limit 100 = 100 (no adjustment)
15 NOV --> limit 100-10 = 90 (adjustment per #1)
.
. - repeat concept as above
.
30 NOV --> limit 100-10 = 90 (adjustment per #1)
01 DEC --> limit 100-10 = 90 (adjustment per #1)
02 DEC --> (Friday) --> limit 100-10+20 = 110 (adjustment per #1 & #2)
03 DEC --> limit 100-10 = 90 (adjustment per #1)
.
. - repeat concept as above
.
15 DEC --> limit 100-10 = 90 (adjustment per #1)
16 DEC --> (Friday) --> limit 100+20 = 120 (adjustment per #2)
17 DEC --> limit 100 = 100 (no adjustment)
etc

It gets dirtier !
There are two broad types of leave - general - for which the limit is determined/applied at the (site+workType) level, and "long service" for which the limit is to be applied at just the site level (workType has no bearing).

I was OK up until it got "dirtier" - now I am not so sure....

I was thinking...

tblLimit (base limits)
-------
limitID (PK)
workTypeID (FK to new table tblWorkType)
siteID (FK to new table tblSite)
limit (integer)
effectiveFrom (date/time)
effectiveTo (date/time)


Does my base limit table store WorkTypeID, but as null when the record relates to "long service" leave, and as a valid WorkTypeID when the record relates to "general" leave ? If so, is it of sound design to derive the broad leave type from the "nullness" of the workTypeID, or is it recommended to store that separately?

Similar questions relate to the adjustment table, for both WorkTypeID and WeekdayID...

tblLimitAdjust
-------------
limitAdjustID (PK)
workTypeID (FK)
siteID (FK)
adjustFactor (double)
WeekdayID (FK)
effectiveFrom (date/time)
effectiveTo (date/time)

I was sort of hoping that writing this out may help clarify my mind on some of the points.... which it did, but only to a limited extent so....

Suggestions / corrections / Pointers ???

Regards

John.

View 2 Replies View Related

Field Max Length

Jul 17, 2005

Um, well hi

I am a VB programmer, and need a database for a diary program i am making. Only i need more then 255 characters in one of my fields.

Is this possible, if not, what are my options.

Thank you
ILMV

View 2 Replies View Related

Field Length

Mar 12, 2007

Hi,

I'm looking for some advice on what the maximum field length is in Access. Which option will provide the maximum length. I am wanting the field to capture both numbers and text.

Any pointers in the right direction would be much appreciated.

Thanks in Advance.

View 3 Replies View Related

Tables :: Scheduling Table With Exceptions In Database

Apr 9, 2014

I have a normal schedule table in my database that stores the open/close hours for each business unit location.

The problem is some locations are timeshares and some have different business units every other week, every 2 Tuesday, the 1st and 3rd weeks of the month.

I figured I would make an exception table noting all of these somehow and after building a calendar/report plug in the exceptions.

View 4 Replies View Related

Forms :: Force Value In Unbound Combo Box?

Mar 26, 2013

Ive got a database with a combo box, called "combo1" (with 2 columns). It is unbound but uses a query as its row source. When i select a value in combo1 is places the data from combo1.column(1) into a textbox (text1). I then click the next record button (button1) and it then keeps the same value in combo1 because it is unbound. So i need it that when i go to the next record it displays the value in combo1 that relates to text1.

View 2 Replies View Related

Memo Field Length

Mar 26, 2007

Hello,

If I read the documentation then memo field in a Access table can be 65.000 chars long.
I have three memo fields in a linked ODBC table which is filled by a append query from SQL-server database. The text in these field is cut off by 255 chars.
Does somebody know what the cause of this can be?

1. Is there a limitation/property where I can configure the length of Access memo field? DAO? I have read something about this but I don't understand this.

2. How can I trace that everything is send from the source? Maybe it's cut off at the source site. On this moment I don't know something about a Linked tabel.
Is there a sniffer or trace tool so that I can see what kind of data is realy send?

Thanks in advance

Nico

View 2 Replies View Related

Storage Length Of Field

Apr 2, 2008

Hi everyone,

I am using a table that stores data and one of the fields is just a text field with a maximum length of 10.

However, when I store the data in the field, if I only enter 5 letters in it, it stores the 5 letter word correctly but followed by some spaces (I assume 5 spaces but I may be wrong.

I cannot figure out why does anyone know why?

If not, then can I trim the field if I use it in a query/report?

Thanks.
Gareth.

View 6 Replies View Related

Forms :: Force A Start Place In A Textbox

Jun 26, 2014

I have a textbox (Odour), that contains one of four words (Cadaver ( ), Drugs ( ), Explosives ( ) or Money ( ) ), the word is written in by pressing one of four buttons, this works fine.

I now want the user to write in between the the brackets and only the brackets. For example:

The textbox contains Cadaver ( ), I want the user to be able to write between the brackets "Blood".

I seem to recall that there is a way of only allowing the user to type in certain places within a textbox.

View 2 Replies View Related

Forms :: Force Users To Enter Data

Aug 4, 2015

My database is tracking Job/Project information. The users must assign the Job Contacts which can be both internal and external (ie: Contracts is a Client Contact, while Engineer is an Internal position)..

tblContactTypes which defines each of the 10 types of job contacts.
fldTypeID: fldTitle fldClient fldInternal
1 Contracts True False
2 Engineer False True
3 Other True True

The Job Specific data is stored in tblJob_Contacts

fldJobID (PrimaryKey)
fldTypeID (from tblContactTypes)
fldEEID for Internal Contacts (from tblEE)
fldContactID for External Contacts (from tblClientContacts)

My question is this...How can I force the user to enter the Contact information for Contact Types 1,2,3, and 4 while leaving the remaining contacts types as optional?

I would like a form with combo boxes for the first four Contact Types which must be assigned for every job and then a continuous subform where the user can assign the remaining contact types if needed.

Initially, I planned to store the first four Contact Types as separate fields in the main table (tblJob) - however, distribution lists are needed and it makes more sense for all the contact information to be stored in the same table.

View 2 Replies View Related

Field Length Cutting Off When Exporting To Cvs

Mar 12, 2008

I know zero about Access and am posting this for another organization. When exporting to cvs, one of the fields is not exporting the entire text. It's a text-only field with about 300 characters. Is there a limit? Seems they had had this problem in the past, but fixed it. Can't find the solution again. Help and thanks!

View 3 Replies View Related

Fixed Character Length Of Field

Sep 29, 2011

I have a column in my table, and its size is set to 10 characters. In a form, i have a combobox based on that column, which contains the values "Corrective", "Preventive", and "Supplier". both Corrective and Preventive are 10 characters, and fill up the field to its max, however, Supplier is only 8 characters. When I look back in the table data, there are two spaces after Supplier. Basically, I can use the arrow keys to "see" the two blank character spaces. Why is that? Are these extra blank spaces taking up space they shouldn't?

View 3 Replies View Related

Forms :: How To Force Execution Of A Query When Changing Record

Jul 13, 2014

I have the following tables:

Supplier
Supplier# [Other columns]

Material
Supplier# Material# [Other columns]

DeliveryHeader
Delivery# Supplier# [Other columns]

DeliveryDetail
Delivery# Supplier# Material# [Other columns]

I've created a form based on table DeliveryHeader with a subform based on table DeliveryDetail. The two are linked by Delivery# Supplier#.

On the form, Supplier# is a combobox that lists all suppliers from table Supplier.
On the subform, Material# is a combobox that lists only the materials supplied by the supplier selected with form's Supplier#.

The problem is that this second list always shows the materials of the first listed supplier. For instance, when the form is loaded, it shows delivery #1 with all its details on the subform. Suppose supplier loaded to form is #1.

1) If I use subform combobox, it shows correctly supplier's #1 materials. But then, whatever delivery I navigate, it always shows supplier's #1 materials.

2) If I navigate to another delivery without using subform combobox, suppose I stop on a delivery where the supplier is #4, then subform combobox shows correctly supplier's #4 materials. But then, once again, whatever delivery I navigate, it always shows supplier's #4 materials.

I've spread Me.Requery here and there but without any success. What trick must I apply to force the execution of the query of the subform combobox Material# each time I navigate to a new record on the form?

View 4 Replies View Related

Changing Field Length In Large Database.

Feb 6, 2006

I am trying to change a field lenght of a large database (access 97) It is at 50 right now and want to change it to 25. When I try to change it and save the table I get a error when the bar is about 3/4 the way accross the bottom.

Microsoft can't change the data type - there isn't enough disk space or memory.

then

not enough space on temporary disk

This is error 3183. In the help it says that the TEMP DOS enviroment variable location doesn't have enough space. (summerising). Now I have a 100+gb drive that isn't close to being full. I also changed the MaxLocksPerFile registry dword to 8,000,000 as my table has around over 3 million records. I have tried this on a xp and 2000 machine same results. Next I am going to try it on a 98 machine. I could do it by breaking up the table into 2 differnt ones and do each one individually but there is an autonumber field used as a reference number (I know I know). So that would screw up the numbering scheem (Yes I know there are ways arund that also). this database is about 400MB

Couple of questions
1. Is there a way around this? I have not found a solution on line yet.
2. Will lowering the field length make the database smaller (the data that is in there now is less than 25 charecters and the field is set to 50.) I have gotten mixed info on this. there are a few fields I would like to reduce.

Thanks
sam

View 2 Replies View Related

Update Query Based On Length Of Value In Field

Jul 12, 2007

I want to create an query that will update a field value for records where the length of the field value is less than a given number (if LEN of UniqueID is less than 6 for example), but I can't figure out how to write a SELECT query, much less an UPDATE query for this condition....can someone help me, please?

View 1 Replies View Related

Modules & VBA :: Add Text To Make Max Length In Field

Sep 26, 2014

I have 2 fields in a query which I want to write to a table. Eg ProductName (field length 10) and Product Code (field length 5) the fields need to be filled out so the length makes the maximum text

For example product name 'test' length is 4 i have to add 0 to make the length to 10 so the field will be 000000test same thing applies to Product code. I have 700 records like this, is there a way in VBA where it adds the extra text to make it the maximum length.

View 14 Replies View Related

Modules & VBA :: Check Length Of A Field Value In The Table

Jul 29, 2015

I have a table that stores ID,PolicyNumber,NewPolNo fields.It has millions of records. The field NewPolNo is empty. I need vba code that will check the following for each record:

1. If the length of the PolicyNumber is over 14 characters long then store that PolicyNumber value in NewPolNo field.

2. If the length of the PolicyNumber is less than 14 characters long thenagain store that PolicyNumber value in NewPolNo field.

3. But if the length of the policyNumber equals to 14 digits long then check the following:

a) If the last 7 digits are 0's of that PolicyNumber. If yes then store first 7 digits in NewPolNo field.
b) If the last 7 digits are not 0's then store the whole PolicyNumber value in NewPolNo field.

We need to check these conditions for each record of the table.

View 1 Replies View Related

Modules & VBA :: Increment Variable Length Alpha Numeric Field By 1

Jul 8, 2013

I have a database that is used for tracking changes to numerous courses. Part of this database create a unique tracking number for each course problem developed. Currently I have the form do a comparison using the highest most number to compare against the current number assigned and prevent the form from saving until the number is incremented and not a duplicate, it would be a lot easier if I could just have it increment plus 1. I have seen various answers but they all seem to depend on the alpha portion of the field being a set value, in my instance it is variable in length. The only part that is fixed is the last four characters to the right which are the numeric portion I would like to increment. For example the field can equal:

QACP-M-PIQ-6059
QACP-M-PREF-6002

how to extract just the numeric portion, increment it by one and save?

View 2 Replies View Related

Tables :: Length Of Text Field - MS Access Can't Change Data Type

Aug 6, 2014

I have a table with about 300,000 records. About ten fairly small fields per record. I am trying to change the length of a text field from 25 to 40 characters, and I get the error message, 'MS Access can't change the data type. There isn't enough disk space or memory'.

I have never seen this message before. I have about 64 Gig of free disk space. What can I do?

View 4 Replies View Related

Forms :: Max Length Of Text Box Input Mask?

Jul 9, 2013

I'm trying to apply a custom input mask to a text box control. The text box must contain a 43 character string, broken into sections as follows :

AAAA-AAAAA-AAAAA-AAAAAA-AAAAAAAAA-AAAAAAAAAAA-AAA

(The format is quite strict and always comprises alphanumeric characters , hence I figured an input mask would, if nothing else, support the user to key the string accurately from its constituent parts...)

However, when I try to apply the input mask to the text box, I seem to run out of characters - I get as far as the below but the input mask wizard won't let me extend the mask to the final 8 characters

AAAA-AAAAA-AAAAA-AAAAAA-AAAAAAAAA-AAAAAAAAAAA-AAA

Are input masks restricted to 35 characters in length? And if so, how else could I make this, admittedly complex, text input more manageable for end users?

View 2 Replies View Related







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