I am experiencing an issue with the following code. The code works fine, I'm just not sure where to place it on a subform in a Tab Control to ensure that all validation is done before the user can move to another tab.
Any ideas what event I need place this on? I tried the BeforeUpdate and it popped up first error box, but then proceeded onto the next tab that I clicked.
Thanks!
'Enforce required fields on a form
Dim ctl As Control
For Each ctl In Me
If ctl.Tag = "Required" Then
If IsNull(ctl) Or ctl = "" Then
MsgBox "You must complete all required fields to continue", vbCritical, "Required Field"
ctl.SetFocus
Exit Sub
End If
End If
Next
'All fields are validated, now set ctl to essentially being unbound
I have an Employee Database with a form that displays the employee record. When an employee leaves they want to be able to click on a button on the form and have the record moved to a different table. My thought was to do a append query to move the record from my active employee table to the termed employee table, but that would still leave a copy in my active table. I'm not real up on coding that much so Im not sure if there's a way to have code move a record from 1 table to another table or copy the data from 1 table to another table and delete it from the first table. Any help would be greatly appreciated.
I have read a couple of threads about what I am trying to do on other forums and I wanted your views please.
Basically I have to Forms, on form one I have a basic quote generator which will output a specific value in a textbox in form one. If that quote is accepted I would like that value to be feed through to a field in form2 which is linked to a table. I have a button "Accept quote", on form one which opens a new record in the table feeind form 2.
Ok i'm opening a form with the intention of grabbing the last reference number and adding one then moving to a new record.
However the form opens on the first record. Here is my code.
Private Sub Form_Open(Cancel As Integer) Dim lastbookref As String Dim expans As String Dim Newbookref As Integer Form_frmbooking.RecordSource = "SELECT tblbooking.Bookingno, tblbooking.Clientno, tblbooking.Sampledate, tblbooking.Sampleref, tblbooking.[Sample place], tblbooking.Recieveddate, tblbooking.Recievedby FROM tblbooking WHERE (((tblbooking.Bookingno) Like """ & Left(Form_frmClient.Clientname, 3) & "*""));"
If Form_frmbooking.Recordset.BOF = True Then Form_frmbooking.Bookingno = Left(Form_frmClient.Clientname, 3) & "/00/0001" Else Form_frmbooking.Recordset.MoveLast lastbookref = Form_frmbooking.Bookingno DoCmd.GoToRecord , , acNewRec
Newbookref = Val(Right(lastbookref, 4)) + 1 Select Case Newbookref Case Is < 10 expans = "000" & Newbookref Case Is < 100 expans = "00" & Newbookref Case Is < 1000 expans = "0" & Newbookref End Select Form_frmbooking.Bookingno = Left(Form_frmClient.Clientname, 3) & "/00/" & expans End If End Sub
Anyone have any idea why this is not moving the new record.
Even more bizarrely the new booking reference is inserted into the new record....its just that the form opens up on the first record.
I need to display some of the insruction lines in unbound / bound text box that will gradually moves up.
Example :
"This multiuser client server db is licenced to "ABC & Co.". This sofrware is to reduce cost of production and it increases speed of your production process more...."
These instruction lines may be arojnd 10-15 lines. I need to display it as non-stop moving up text massages on the main form once the data base is opened.
I'd like to do the following: when the user does something on Form A, Form B has to be open and the Forms should be located on the sides (Form A to the left side, Form B to the right side) of the display so the user can see them at a time.
However both Form A and Form B has an automatic centering function set when used alone.
Is there a way I could push this from code? I can't fine anything like that among the form's property.
There are some selection controls that require the user to enter data before the next one becomes enabled.
My form then has two different groups of controls that the user see's depending on the selections earlier, either one group or the other is made visible.
My question is how to move the view so that the appropriate group is where I want it.
If I use setfocus to a control the form moves but not how I want it to (The control that i setfocus on is half way up the screen rather than close to the top.).
I know there must be a better way, I tried move size but it didn't seem to do what i wanted.
I've created a form. Within that form I have an image control. I am using this code to pull the corresponding plant image from a folder filled with JPGs.
It works just fine except one thing. When I change from record to record my cursor jumps to the center of the pulled JPG. I don't want my cursor to move at all when loading these images. Is this possible? Thanks.
Private Sub Form_Current()
Dim FileExistsbol As Boolean Dim stFileName As String
I would like to be able to switch between these two forms and the form automatically set focus to the record that I was on the form prior. Meaning if I am on record 3 on Form A and navigate to Form B, I would like to automatically set focus to record 3. Is this possible?
A possible issue after this gets sorted out is what happens if with the same scenario above record 3 does not exits? is it possible in that instance to simply requery the form?
Issue with Cursor moving on multi Subforms in a form.
I have 2 sub-forms in a main form as per screenshot. So Cursor moving from main form to 1st subform working well. After can't move the cursor from 1st subform to 2nd subform with tabbing or entering. Still there in 1st Subform in the last entered filed after tabbing or entering. I've checked on tab orders also they shown correct but it is can't move to 2nd subform.
I have created a Form based from a Table. On one of the fields, I need to be required inside the Form before moving to the next record of that form. I can not make the required field in the table, because I have to append information day to day.
Also, the required field is a combo box option that is limit to the list.
What kind of Code I can do inside the form of the specific field to make it required before clicking onto the next record. It does not matter if the processor closes out of the form before updating, only if moving to the next record.
I have a form in which user will enter few values but I need users to enter the comment in relevant text box too only if they have any non zero value.
I have attached an example for reference....where red encircled portion is for values and blue is for relevant comments. If value is non zero then user should be enforced to enter the comment too......system should not allow user to move forward or backward until there is some comment.
Hi I would like to ensure all fields on the form are filled before a user exits the db. I have a quit button on my form and it is there for people to exit entirely from access. I need to validate the form and display a message if not all fields are filled. This way i will safeguard against any bad records.
how do i look through all the records to display a message and wait til they follow a procedure before exiting?
I am trying to validate fields in a form, before an email is sent saying the form is OK. this is my code :
Private Sub Save_Click()
If Me.Team = "" Then MsgBox "You must enter your Team name", "Data Validation" Me.Team.SetFocus
ElseIf Me.Customer = "" Then MsgBox "You must enter the Customer Name", "Data Validation" Me.Team.SetFocus
ElseIf Me.Address = "" Then MsgBox "Your must enter the 1st line of the address", "Data Validation" Me.Address.SetFocus
ElseIf Me.Address1 = "" Then MsgBox "You must enter the 2nd line of the address", "Data Validation" Me.Address1.SetFocus
ElseIf Me.QueryContact = "" Then MsgBox "You must enter a Contact name", "Data Validation" Me.QueryContact.SetFocus
ElseIf Me.QueryPhone = "" Then MsgBox "You must enter a Contact telephone number", "Data Validation" Me.QueryPhone.SetFocus End If
DoCmd.Save DoCmd.SendObject , , , Me.ReqBy, , , "Invoice Requisition " & Me.HeaderID, "You have submiited an Invoice Requistion to Finance. The requistion was too " & Me.Customer & " and totalled " & Me.InvTotal & ". You will receive a further email confirming the Invoice Number, once Finance have issued the invoice.", no DoCmd.SendObject , , , "lee.mason", , , "Invoice Requistion " & Me.HeaderID, "An invoice requisition from " & Me.ReqBy & " is waiting to be authorised.", no
End Sub
Can someone please explain why the email sends, even though some of the fields are not completed.
When user submits record on form, by pushing the arrow to move forward to new form, or back to previous ones, I would like to ensure that they have met a specific criteria in some fields.
How can I catch this without using VB Access? I can use VB Access, but would like to know how "normal" users would force form validation.
I have a problem regarding how to validate data that the users of my database must enter. I have two tables that relate to this. The first it a booking table.
This table named tblBooking contains: Booking ID Client Date Label (Name of the Timetable slot) Event Name Paid?
The second table contains all the information on the timetable slots. These slots are 10:30am to 12pm(Morning), 1pm to 5pm(Afternoon), 6pm to 9pm(Night), and 6pm to 11pm(Late Night). The table is called tbltimetable and contains: Label Start Time End Time Cost
The problem is that a user can enter the database, open the booking form, and enter conflicting data. E.G two clients can have the same 6pm to 9pm booking, on the same date.
Another problem is that the final two slots of the time table are also conflicting, e.g, one client can have a 6pm to 9pm booking, and another can have a 6pm to 11pm booking.
Obviously, neither of these situations are possible, so I wish to add some validation that will prompt the user to choose another date when they pick a date/timetable slot combination that has already been taken.
I assume that I will have to impliment this using the forms, as it is not possible to add this amount of validaition in the table design. The thing is, I dont have any ideas on how to do this, and I have only just started to learn VB if that is what i have to do. If anyone can give me any feedback and help me to learn how to solve this problem, either through the booking form, or a better way, then I would be very grateful.
On another note, i would have posted the database, but it is 41mb, and only has about 10 records in each table. Does anyone know why this could be? I have already compacted and repaired the database, as it used to be 39mb.
If you have any questions please do not hesitate to contact me.
Thanks for taking the time to read my post. Best Regards Chris Grant
This is probably an easy question for most of you out there, but it has me stumped as a novice in this field.
I have a combo box on a form that has a row source defined to come from a query. I have the "limit to list" option set to "YES" in the properties of the combo box. My issue is this, when a end user enters a value into the combo box manually, instead of using the drop down data, and that value is not in the related query, can I define what is said in the text box that appears, in place of the access default error message?
Second question is related to that, the system will not let me continue until I enter a value in the combo box that is on my query. Can I, from the text box that I have come up, jump to another form where I can update the records that the query is pulled from?
Here are the specifics for my database. Combo box is on a form dealing with my "tote tracking" table. The box specificlly deals with the "serial #" field on that table.
I do not want the to be able to 'move' a tote unless that tote serial number has been enterd on the "tote setup" table, which the combo box is limited to search from. If you try to enter a tote number that has not been setup, the "limit to list" feature will not let it happen. I would like my own error message to come up, and woud like to hit a control on that message to go to a form that enters records in the "tote setup" table. Then you will have the chance to 'set up a new tote' and create a record on that table from which the origional form would be able to pull.
Any help you could lend on this would be appreciated, I am new to access and trying to learn on my own...
I have a form that requires people to enter a number of values. The sum of these values cannot exceed 100. The values are stored in a table for later use. I also want to catch the error here with a message.
I have a simple form with a save button created directly from a table. I would like the on click event to check 4 fields to be sure that they weren't left blank and have a msgbox prompting to fill in the missing data, obviously not saving until all fields are complete. Fields are FirstName LastName Age Position. If all data is filled I would like the button to save the record and begin new record.
Hello, I'm having difficulty with a validation rule in a form. I have a numeric field I want to limit users to entering a number between 1 and a variable second number. The second number is the number of records in the table. So if the table has 5 record, the user can enter a number between 1 and 5. When the number of records increases to say 15, then the user should be able to enter a number between 1 and 15.
What I have done so far is as follows:
Function MyValRul() MyValRul = "Between 1 And " & DCount("*", "tblRegion1") End Function
and in the validation rule option for the field on the form I enter =MyValRul()
This should returns a value like Between 1 and 15
But it does not work. I do not get any programming errors but when I attempt to enter a number in the field I get the validation error message even if I enter a number that IS valid.
Any assistance will be greatly appreciated. And please be gentle (i.e. keep it simple and include detailed step by step instructions) I am new to Access and vba.
I want to include a validation on a form. I have an auto number field called ID and a field called Nature Of Incident. I only want to have the auto number generated if the Nature of Incident is NotNull.