First off let me say there is some terrific info here on this site, great job! Also, let me state that I'm designing my first database so I'll likely be asking some really stupid questions.
I'm designing a database which will allow customer work orders to be entered. The main form is pretty big but it requires a lot of info. Eventually I want to add a search option that will allow the user to search for all records for a specific customer, or address.
Anyway, I had an Add Record button working but it was causing other problems so I had somebody help me out but now I have problems with what they added to the add record button. If some of the required fields are not filled out there is no action when the add record button is pushed. I was getting into an endless loop because the "Resume" command was in the code so I took it out. Can anybody help me with this please?
Here's the code on the Add Record button:
Private Sub addnew_Click()
On Error GoTo Err_addnew_Click
DoCmd.GoToRecord , , acNewRec
Exit_addnew_Click:
MsgBox "customer added", vbOKOnly, App.Title
Exit Sub
I have this code on the a Close Button and if the record is incomplete I want it to be deleted from the table. The ID field is an autonumber so it is the 1st field to get a value if a user starts entering data. I get a msg box saying 0 fileds will be deleted why? the id's do match but it does not delete??
Ive added my own navigation buttons as I needed to add some code to them, but when a user gets to the first / last records & presses previous / next record, they get an error message 'cannot go to the specified record' and have to close & reopen the form. It's prob. quite simple, but how do I get round this please?
This should be an easy one...I would like to save a record part-way while filling out a form. I know this can be accomplished by pressing Shift+Enter, but does anyone know the vb code for saving a record while working on a form?
I have a form where people can enter multiple records. In a command button on that form I have code that assigns a unique identifier for the record. Unfortunately I am getting an error and I think it is b/c the code is not running for each record. Is there a way to tell the code to run once for each record?
does anyone know the code to save a report with a changing file name?
here are the details. i have a reoprt that changes weekly. i want to save a weekly file with the end result to be called "Downtime Cost Report #/##/##", where the date is pulled in from a qry called "qry_Actual_Costs_Thru" and field name [Fiscal Week].
I have a form that shows employee license information. I also have a query & form based on that query to show licenses currently suspended. I would like to on my employees form to flash "license suspended" label if their name/record id is on the license suspension query. For all employees whose license isn't suspensed I would don't want anything to show. I can get the label to flash and to appear. I just need help evaluating the query and comparing it to the current record. Example I
if me.id = queryname.id then....execute label flashing, etc.
I'm going live with my DB tomorrow morning. I wanted to to Edited Records for my lock type but ran into a problem, this weekend when I took it to our office and had it on multiple computers for the first time. (I've been designing at my house, in my spare time (right), so I couldn't test for the problem I have now.) When a user is on a record and I open the same record up on another computer it locks ok and shows in the Record Selector that it's locked but if I begin to tab through the form I have at least one code that pukes. In my LastName field, in the On Exit event, I have the following code: If Not (IsNull(Me.LastName)) Then Me.LastName = StrConv(Me.LastName, vbProperCase) End If As I try to Exit this field, only when the record is locked, the code pukes. Can some one lend a hand and give some advise on how to prevent this?
I'm trying to set up a looping code to go thru each record in a query. I know in excel I would set the cell value to a range and offset to get to the next value. How is this done in Access?
Hello, I need some help. I have a form named MASTER based on a table also called MASTER. A control of my form in names SSN which stores the client SSN.
On the same form I have placed a subform which has its record source to a table named 21.
What I am trying to do is: When I enter a new record in my form MASTER, the code should: 1) Verify if in table 21 a record with that SSN already exists. If YES, skip the code and do not add the SSN. If NO, well, run the appendquery.
2) At the same time, verify if a record with that SSN already exists in table MASTER. If NO, add the data, if YES, abort the code and exit the form.
The form EForms is a menu form I use to access the records.
This is the code. Something is not going right, I think with the end if functions. Any help? I have placed the code in the AfterUpdate event of my control SSN.
Dim mydb As DAO.Database, MyRs As DAO.Recordset Dim strCode As String Dim strFilter As String Dim stDocName As String Dim stLinkCriteria As String
Set mydb = CurrentDb Set MyRs = mydb.OpenRecordset("master")
stDocName = "MASTER"
stLinkCriteria = "[SSN]=" & "'" & Me![SSN] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
If Not IsNull(DLookup("[SSN]", "21", "[SSN] = '" & Me!SSN & "'")) Then Forms("EFORMS").Visible = False Else If IsNull(DLookup("[SSN]", "21", "[SSN] = '" & Me!SSN & "'")) Then DoCmd.OpenQuery ("Appendssa21tax") End If End If
If Not IsNull(DLookup("[SSN]", "MASTER", "[SSN] = '" & Me!SSN & "'")) Then MsgBox "Sorry! A record with this SSN is already in file. Retrive case from E-Forms Menu.", vbOKOnly, "Warning" DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70 DoCmd.Close End If Forms!eforms.lstPreInterview.Value = Null DoCmd.Close DoCmd.OpenForm ("Eforms") DoCmd.RunMacro ("CloseEforms") DoCmd.OpenForm ("Eforms") End If
I have a form based on a query and have written code to display a msgbox if a duplicate entry is inputted in the NHS_Number field in the form. I have also added code "me.undo" to clear the form so that it is not saved. I am looking for a piece of code that will display the duplicate record. Here is my code thus far:
Private Sub NHs_Number_BeforeUpdate(Cancel As Integer) Dim dbs As Database Dim rst As DAO.Recordset Dim x As Integer
I have database which holds records dating back 4 years. I am trying to create a code to list all records into report older than 3 years from current date, every time I run the code. The problem is I cant get the date part to work (highlighted in red) . I have tried various date options. The [datepickedup] is the date.
Private Sub Form_Load() Dim intStore As Integer DoCmd.Maximize intStore = DCount("[ReferenceNo]", "[WasteCollectionRecord]", "[DatePickedup] and [datepickedup]< #" & Date & "#- 1095") 'If count of uncomplete jobs is zero display switchboardor 'Else display message box detailing amount of jobs
I am currently in the middle of creating a database as a means of keeping records of vouchers codes. When someone uses a voucher, I will then be able to input the name of the customer with the voucher code in the form.
This is meant to do two processes:
1. Keep a record of who has used a voucher 2. Check and validate the voucher code (the codes are kept in a table).
Now, I have created 90% of the db to input the customers details etc BUT...I am struggling for the validation part. Ideally, the db would also remove the said voucher code from the table so the same voucher code can not be used more then once.
I was going to "pre-install" the voucher codes in the db and then print off the vouchers for distribution. But I am basically tying to make the system so that it cannot be abused (for obvious reasons)...
So I have a form which is showing the current record and you can scroll through these and make modifications to them from the form as opposed to using a table.
The form has the following fields populated from the main table
Customer name (Can appear more than once) Status Date Servers Positions
In addition it has several buttons for next record, previous record, first & last record, new record, delete record and update record.On this form i have a text box that i want to be able to use to search for a record using the customer name when you press the search button associated with it. I've got some code and it is mostly working but it seems to be moving the text entry cursor to the date box of the record for some reason.
What I want it to do is take the text from the search box and find it and move the form to that record.
Code: Private Sub btn_cstmr_srch_DblClick(Cancel As Integer) On Error GoTo HandleError Dim strFindWhat As String strFindWhat = Me.txt_cust_search.Value
For whatever reason, this code will move to the last record that was entered in YESTERDAY, but I want it to move to the last record that was entered in TODAY. If I change the code to only records that are dated today, it claims there are no records (EOF), when there clearly are. why the code will not move to the last record of the table, it is only moving to the last record that was entered yesterday.
I have a report with several sub reports that run and fill a table conditionally. The third sub report displays the records from this table. It works perfectly.
If I print a batch of records, it also works perfectly - but only for the first record. Previously, I had another report with several sub reports where the visibility of objects were controlled - this worked fine in a batch. Every subreport had the correct visibility settings.
In this case, I have a similar design, but instead of setting visibility on the various subreports, I am filling a table based on data in the subreport. As stated it works great for the first one in the group, or any single print.
I have a multi-select list box for selecting which faculty members apply to a project. The faculty table and project table are linked in a many-to-many relationship. I have the following code which should create entries in the link table:
Private Sub Command5_Click() Dim varItm As Variant
For Each varItm In lstFaculty.ItemsSelected rs.AddNew rs!FacultyID = Me.lstFaculty rs!EntryID = Me.EntryID rs.Update Next varItm
rs.Close Set rs = Nothing End Sub
It successfully creates new records and enters the EntryID and LinkID (autonumber). However, FacultyID is always left blank. lstFaculty is the unbound list box which has three columns from the faculty table and is bound to FacultyID. Any ideas on why FacultyID isn't created in the link table (I get no error messages)?
Also, any ideas on how to prevent duplicate links being created every time the button is pushed? I was planning on having it first run a delete query for that EntryID in the link table so that it replaces the old links and any that have now been unselected are no longer linked. Comments on that idea?
Thanks again to everyone on the forums for your help.
In trying to respond to another thread, I have run into something that is confounding me (or maybe I'm just getting dense).
We have a subform. One field has an event on DblClick to launch a search form. When the user identifies the target, he/she clicks a button on the subform. This pushes the appropriate value into a field on the original subform using VBA code and closes the search form. This all works fine.
The behaviour that is driving me bugging is when the user clicks on a new record (i.e. new line) on the subform, we would like to automatically generate the next record (E.g. when you type in a field of a record with autonumber in datasheet mode, Access automatically generates the next record). Currently this doesn't happen - Access generates the PK for the record being modified, but doesn't generate the view of the next record.
What really confuses me is that I have created similar looking example in which this works just fine. I can't figure out which of the differences between the two samples is causing this behaving.
Also, typing information into the field on the subform does cause the next record to be generated. It is just doing this via code that works in one case but not another.
I have narrowed it down to the actual subform. Even as a standalone form the form exhibits the same behaviour.
For reference, the original thread is http://www.access-programmers.co.uk/forums/showthread.php?t=99457
URL...Essentially it seems like the format event fires only once with a docmd that has a where clause. If I print a single report it is perfect! Example one in the above post has a subreport, example 2 its very simply incorporated into the main report with no sub report.