Help Me With Code For Adding And Editing Records Using Forms.

Jan 29, 2006

Hi,
I have the following situation.
I have a switchboard form which has 2 buttons (Add And Edit)
I have a patient record form, which has 2 fields, (DateRecCaptured and DateRecUpdated)
Both buttons on the switchboard open the Patient Record form (one opens it in Add mode and the other in Edit mode)

This is what should happen.
If I click on the add button on the switchboard, the patient record form should open to allow me to add a record. The system date should then automatically be saved in the DateRecCaptured field.
If i click on the Edit button and edit a record, the system date should be saved in the DateRecUpdated field. If no updates are made, the field shouldn't be updated. If you scroll among records, the DateRecUpdated field shouldn't be updated. When editing, the DateRecCaptured field should remain unchanged.

Thanx

View Replies


ADVERTISEMENT

Modules & VBA :: Adding And Editing Records From Unbound Fields

Mar 4, 2015

I total novice at VBA. I am trying to code a button to modify (the last) record in a subform list and then add a new record based on values in unrelated or unbound fields on the button form.

The following code is based on the first of two YouTube tutorials (this bit on the edit) and looks like it should work. Except that my Access 2010 with Visual Basic for Aplication v7 does not recognise the type definition Database or Recordset

Code:
Private Sub ANOwner_Click()
Dim cn As Integer
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb

[Code] .....

View 6 Replies View Related

Editing Records With Forms

Oct 24, 2005

Hi everybody,

I have a large problem which I can't figure out (well 2 actually but the other is less important):

1) I have a form which brings up the results of a search performed by the user (only contains some fields). From this list of results i would like the user to be able to a) see a full report of that Record (which I've done ok) and b) edit the data contained in that Record.

My results form opens the editing form no problems, however, i cannot edit any of the data contained within it. This only occurs when the results form is open as well so i guess it's because there are two instances of those fields open simultaneously. However, I am reluctant to close the results form because the results will be lost.

2) I've tried several methods to open the form at the desired record:
- using the WHERE condition argument of the OpenForm function
- creating a filter in the editing form that runs in the OnOpen event
These two require the creation of a variable (I'm using the Key field) that is inserted into these bits of code. However, all of my attempts thus far have been unsuccessful; every time it asks for the Parameter in a popup. I've defined the variable as a Public variable in a seperate module but don't really understand this aspect partcularly well; I'm obviously missing something.
- the form currently opens from it's own query that gets the Key Field Criteria form a hidden control on the results form.

Here is my code for the 'Edit' button:

Public stProjectID As String

'Results form 'Edit' button click:
Private Sub btnEdit_Click()
stProjectID = txtID2
[Forms]![frmResults].Visible = False
DoCmd.OpenForm "frmProjectEdit", acNormal
End Sub

'Edit' form open:
Private Sub Form_Open(Cancel As Integer)
Me.Filter = "ProjectID = stProjectID"
FilterOn = True
End Sub

Sorry for waffling on...

Thanks in advance for your help.

Bobadopolis

View 2 Replies View Related

Forms :: Editing Records Through A Form

Aug 13, 2014

Just a general query about the best approach to take for an editing form.

I want to have two separate forms, one for adding a new record (have completed this) and one for choosing and then editing a selected record.

I have seen that people use combo boxes to display a list of records with fields. This seems quite difficult to use. Maybe that's the best way though?

How do you apply an edit button to a selected record in this type of situation? I suppose really I need a box that has a list of records with a little edit button next to each one, or can I do something that launches the edit form as soon as you click on a specific record?

View 2 Replies View Related

Forms :: Subform For Editing And New Records?

Nov 1, 2013

I've got a master form, which is used to search for records, and display links to them in a list box. When the user selects a record, they get the full details of the record on a subform. At the top of the subform, I have two buttons, an edit button, which allows them to make changes to the record, and a "new" button, which allows them to create a new record.

My problem is, after a new record is created, the subform adds a new page. So instead of having record one of 1, it shows record 2 of 2. So if a new record is saved, and the user tries to access another record, nothing appears because the subform stays on record 2 of 2(which is a blank undirtied record). If you press navigation button back it will show the record they selected.

Maybe I could make the new form a pop up form, and pass it parameters rather than making a new form within the subform.

I've tried putting the command DoCmd.GoToRecord , , acPrevious in the subforms Current() method, but I get an error saying I cannot go to the previous record.

View 2 Replies View Related

Forms :: Search Multiple Fields In Table And Open Matching Records For Editing

Dec 10, 2014

Create form to search multiple fields in table

Return records that match search

Open the record that you want in Form View for editing

View 1 Replies View Related

Text Box, Adding But No Editing

Jan 31, 2006

I have a text box that I only want people to add new data to. I would like them to be able to view previously entered data but not able to edit it. I've tried to lock the data but then I can't add new data.

Any suggestions appreciated,
Joe

View 1 Replies View Related

Preventing Users From Editing Code For A Database

Feb 25, 2014

I have an access database which was created in 2003. I opened a blank database and imported the definition and data in access 2010 and made the file an accde file. Now this file has a lock symbol next to the access symbol. I am also unable to edit the main form.

View 7 Replies View Related

Forms :: Adding Onbeforeupdate Vb Code To Account For Missing Required Fields

Apr 4, 2014

I need code that I can incorporate with the code below, that will notify a user when required fields are left blank so that they have to go back and fill it in before updating the record. Below are the objects (shown in the order they appear on the form):

cmbModel
txtSerialNo
txtExpDate
txtPONo
cmbOfficeLoc

If any of the objects above are empty, the user should be prompted to go back and fill them in setting the focus back to the first empty object (again the fields above are in order). If conditions are not met, do not run the code below. If the conditions are met then proceed with the code below.

Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strMsg As String
Dim iResponse As Integer

' Specify the message to display.
strMsg = "Do you wish to save the changes?" & Chr(10)
strMsg = strMsg & "Click Yes to Save or No to Discard changes."

[Code] ......

View 14 Replies View Related

Adding Records In Forms

Jul 27, 2006

Hopefully I have provided enough info as I have tried to keep it concise...

I am adding records to both a parent table and a child table using a form (for the parent db) and a subform (for the child db). When enterring data into the subform, I would like all previous records enterred into the subform (for a given entry in the main form) to remain visible as new records are entered (rather than simply having the view switch from one record to the next). A follow-up question would be...how do I get a unique identifier variable to increment one unit every time I add a new record into the subform, e.g.

ID var1
1 a
2 b
3 c
4 d
. .
. .


Many thanks - Zach

View 1 Replies View Related

Forms :: Adding Records Only?

Apr 3, 2014

How do I configure a form so it can only add records. I don't want users to see what is currently stored in the table, just add records to it.

View 2 Replies View Related

Forms :: Sorting Records In A Combo With Code?

Apr 25, 2014

Can you have a saved (unsorted) query as a row source for a combo and then add some code to enable the combo to sort the list?

Reason is, I want three combos to use the same query for finding records in different ways, but need the query to be saved, not a query built by the query builder that access takes you into from the row source on the combo data tab?

I only need the data listed in each of the combos to be sorted by one column in each of the combos.

Have seen something about bubble sorting, but not sure if this is OTT or even could be applied to this?

FYI, this is not a cascading situation.

View 2 Replies View Related

Forms :: Running Code On Individual Records

Mar 20, 2015

So in my database i'm creating a live form that will open up a list of patients and when they are seen. one of the bits is a button that before they arrive says "Not Arrived" and after they arrive it says "Arrived". The code works fine:

Code:
Private Sub Command68_Click()
Dim C1 As String
Dim C2 As String

[code]...

The problem is after clicking the button on any of the records, it changes the text on all records, to wit: I tried to attach images or links to images, but my post-count is too low. The before-click screenshot is /3QnBkgG on imgur. The after-click screenshot is 9VZWzzp on the same site.

Bear in mind I've only clicked the button (it's white, so it doesn't look like a button) on the top record.The form is set to continuous forms, not sure if that has anything to do with it.how I can get the code to run on individual records, rather than applying the first-record's results across all records?

View 12 Replies View Related

Forms :: Why Form Adding Records On Its Own

Apr 10, 2015

I start with a table of UserIDs, names and roles (tblUserIDList). I have a simple query off that which lists them in alpha order by UserID. Next I have a simple form with a combo box which uses that query to select the User and binds the UserID field to use.

There is a button which triggers a macro which opens the 2nd form using a query which filters using that UserID. There is another point in that form in which that UserID is again used as a filter for other data. The 2nd form is a data input form. All works fine up to that point.

However, when the 2 forms are closed, for some reason the UserID is re-added to the tblUserIDList. I've never had this happen before.

View 7 Replies View Related

Forms :: Adding Additional Records On Condition

Jun 29, 2013

What I am trying to create is a Despatch database for our warehouse.

Records in table:
Date ()
Customer
Invoice #
Qty of parcels sent
Courier used
consignment number

In most cases we will send one invoice per consignment number (database works fine for this) But on occasion we may send multiple invoices. What I want to be able to do is have a list box to select the number of invoices, this will make available additional fields for Invoice # and Qty of parcels sent. The idea is to get away from keying in the other records for each invoice going to the same place.

View 3 Replies View Related

Forms :: Adding New Records To A Linked Table

Sep 24, 2014

Is it possible to add new records to a linked table ? i tried it out but new records is not possible, is there a workaround for this.

View 8 Replies View Related

Editing Records In A Form

Sep 4, 2005

Hi all
At the moment I have a form which links to a table, one of the columns in the table is called "Description" so the user can input a sentence or two. Basically I when I open this form (in Edit Mode as Im using a Switch Board)it will not allow me to edit a current record.

I can edit a record in the tabel but not in the form.... :eek: .. help

Any help would be superb

Cheers

View 2 Replies View Related

Editing Records In A Form

Oct 25, 2005

I have a very simple form that is populating fields with records from a number of tables (not queries).

I have found that I cannot edit any of the records from the form. Almost all of these fields are NOT key fields. When I click in the field, it simply selects the text in the field, but does not allow me to alter it (typing does nothing...the cursor just blinks). The same thing happens for blank fields.

I know this is a simple question, but I can't find the answer in help or searching this forum. I know it must be a simple setting (I think) somewhere but I've tried a number of settings in properties/forms.

Thanks,

Kelly

View 9 Replies View Related

Editing Multiple Records At Once...?

Jul 6, 2006

Hey guys,
Does anyone have any ideas as to how you might go about editing multiple records at once? So maybe have a listbox with checkboxes, so you can select items in your DB, then, using a form, edit/set one field for all the selected items. Any ideas?

View 4 Replies View Related

Forms :: Unbound Form - Adding Records To Two Tables?

Apr 22, 2013

i have an unbound form with the following code which works as it should

Code:
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("tbl_Courses", dbOpenDynaset)
With rst
.AddNew
rst!DateCreated = DateCreated
rst!Originator = Originator

[code]....

I also need to add other text fields from the unbound form to another table but can't seem to work out how to do it.

View 6 Replies View Related

Forms :: Adding Records - Tabbed Subforms Not Updating

Oct 10, 2014

I have a form with a tabbed area, each tab containing a subform. One of these subforms adds records to a table. Another subform shows the totals from that table.

But when I add records, the totals tab is not updated with the new quantities unless I close the form completely and go back in. I tried adding Me.Dirty = False to the subform that adds the records but that makes no difference.

It seems as though the 'totals' subform gets those values as the form is loaded and does not change, even when records are added and then that tab is selected.

How can I get the totals subform to show the updated totals?

View 5 Replies View Related

Lock A Table For Editing The Records

May 22, 2007

Hello all,

I have a question, I'm building a MS ACCESS database and within it i have a table for putting in my program critical parameters. I don't want anyone to change the content of that table. That means not editing the 1 record in it and not adding a new record. Within the program is't a problem but if you make an other blanc database you can import the table, change it and export it back into the program (i know it is far looking but it happens).

How can i lock a table so it cannot change or it cannot be exported or imported???

View 2 Replies View Related

Prevent The User From Editing Records

May 8, 2005

Hey guys..

is there any way in which i can prevent the user operating a form from adding or deleting or editing any records ?

View 10 Replies View Related

Forms :: Listbox Multiselect - Adding Records To Junction Table

Apr 21, 2014

I would like to use a listbox set to multiselect to add records to a junction table. I've been using code to accomplish this with checkboxes (love how it looks and works) but after moving my tables to Office 365 as the backend, linkedto a local frontend, sql does not like this particular set up, and I do not have the time or knowledge to sort out why. So what I need is a step by step to look at the many, in this case possible roles a contact can have, and choose one or more, which then creates a record in the junction table with the contact id and role id.

I would prefer to not use a combobox on a continuous form because every time a user goes to select roles he would have to scroll through all the choices for each separate role.

View 5 Replies View Related

Forms :: Text Field Auto Update When Adding New Records

Jul 22, 2014

I have 2 tables Master table (Jobs) containing the primary key ("Job Reference") and 2nd table (Candidates) with the foreign key ("Job Reference")

2 Forms

frmJobs Form to view job details
frmCandidates form to view Candates information

I have placed add new candidate button on the frmJobs form which opens the candidate form in the add mode as a blank form. This is fine but I'm looking to add a record where it picks up the "Job Reference" text field value from the main frmJobs and update it in the "Job Refernce" text field on the frmCandidate when I click add new candidate.

How can I achieve this? I'm fairly new to access/vba

View 7 Replies View Related

How To Lock Records To Prevent User Editing?

Feb 6, 2008

Good morning! I'm building a database for use by four technicians in a call-center type operation. The call records are purely transactional in nature -- once the call has been logged, the record is closed. If the customer calls again, a new record is opened.

The supervisor doesn't want the techs to be able to go back and edit a record once it's entered -- the records are for quality-control purposes and he doesn't want them gaming the system by going back and changing things after the initial call is logged (let's not discuss the issue of employee psychology, motivation, Office Space, etc.). So I'm trying to figure out how to do that; they all have wheel mice, and I can currently see all the records as I scroll back and forward with my mouse wheel, so I'm assuming they'll be able to, as well.

Any help?

Thanks,
Andreas

View 11 Replies View Related







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