Modules & VBA :: Inserting Field Value When Adding Record Using Data Entry Form?

Dec 14, 2014

I have a form for entry and some fields are computed or result of a query from another table. I have a function that looks up a value from another table like so

************************************************** ********
Public Function GetTargetType() As Variant
GetTargetType = DLookup("type", "tblFormulations", "[tblFormulations!formulation]=Forms![frmNmsConsumptionEntry]![formulation]")
End Function
************************************************** ********

Which works fine when I test in the immediate window.Then I have this form event. This however does not insert this value when I am adding records using my continuous form.

************************************************** ********
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!target_group = GetTargetType()
'Forms!frmNmsConsumptionEntry!target_group = GetTargetType()
'[tblNmsConsumption.target_group] = GetTargetType()
End Sub
************************************************** ********

making sure I can insert this value once retrieved.

View Replies


ADVERTISEMENT

Modules & VBA :: Can't Get Data Entry Form To Add New Record After First Time

Aug 6, 2013

I've got a data entry form bound to one table. The form has four buttons:

- Clear Fields
- Cancel
- Save and exit
- Save and add another (which should save the user input to the subform/table, clear the input fields, and allow the user to add another record)

I can't quite seem to get the "Save and add another" button to work. When I put some information in the input fields and click the button, it saves it to the subform/table perfectly, but when I try to do it again, it just edits the last record (the one just created).

How can I get that button to place the information from the input fields in a new record every time?

The _Click event for the button looks like this:

Code:
If Len(Me.field1 & Me.field2 & Me.field3) > 0 Then
Me.Refresh
btnClear_Click
DoCmd.Save
End If

View 5 Replies View Related

Modules & VBA :: Check Data On New Record Entry?

Oct 14, 2014

We have a table, JobRegister that people enter information on using a form, FrmOrderEntry

I would like to run a check when a serial number is entered in the field SerialNo to see if the same serial number exists where CompletionDate is null.

this would stop duplicate open orders being put on the system, or new orders being entered where the previous order hasn't been completed.

View 14 Replies View Related

Modules & VBA :: Mandatory Data Entry In Field Before Moving To Another Field

Aug 22, 2014

I have a form that users will use to add new records (customers).

There is a field named VAT_Registration_no

First of all i want some code to check for duplicates in that field only,before entering the next field.If the record exists i want to show a msgbox and set focus to the vat_registration_no field. Also I want the same thing to happen if the vat_registration_no field is empty.here is what i have tried:

Private Sub VAT_registration_no_AfterUpdate()
Dim btest As Boolean
If VAT_registration_no = "" Or IsNull(Me.VAT_registration_no) Then
MsgBox "Please enter a Vat Registration No.", vbOKOnly, "error"
Me.VAT_registration_no.SetFocus
Else
btest = True
End If
End Sub

and to all other fields:

Private Sub textfield_Enter()
If Not btest Then
Me.textfield.SetFocus
End If
End Sub

If I just press enter to go straight to the second field I dont get a msg. If I write something and delete it and press enter i get the msg but when I press ok the cursor goes to the next field. I want it to go to the vat_registration_no field again. And I also want this to happen even if dont write something and then delete it.

View 3 Replies View Related

Modules & VBA :: Datasheet Mode Form For Both Data Entry And Data Retrieval

Feb 9, 2015

I want to use the same form in datasheet mode for data entry and retrieval. When retrieving, all controls are disabled and locked. I am trying to enable and unlock them for modifying but that isn't working.

<code>
DoCmd.OpenForm "PO_Practice Data", , , , acFormEdit, acHidden

Forms![PO_Practice Data]!PO_Name.Enabled = True
Forms![PO_Practice Data]!PO_Name.Locked = False
Forms![PO_Practice Data]!Practice_Name.Enabled = True
Forms![PO_Practice Data]!Practice_Name.Locked = False

[code]...

View 3 Replies View Related

Forms :: Create Data Entry Form To Input Data For Field

Mar 5, 2015

I an trying to create a data entry form (IndividualsEntryFm) to input data for fields such as (First Name),(Birthdate) etc., these to be saved to the (IndividualsTbl)

I also have another table (NamesTbl) which has family names etc. The two tables are linked by a (MainID) field. I want a combo box on the individualsEntryFm so that I can select the family name. Then I wish the empty fields for the IndividualsTbl to be available to enter data.When I press the save button I then want this data saved, together with the MainID from the combo box to the IndividualsTbl.

I have set the IndividualsTbl with a (PersonID) field as an auto number each individual therefore has a unique PersonID but may well share the MainID. I'm trying to link many people to the same address.

View 1 Replies View Related

Modules & VBA :: Linking Tables By Auto Inserting A Record Using Current Record

Aug 19, 2013

I have two forms both with separate tables

(1) Register and
(2) Payments.

One of the common denominators between them is the URN which is auto-populated as it is an auto number field. My issue is that when I want to add a new record to the payments table using the forms (I can get to the payments form via the register form), I want to be able to identify the record that I am currently viewing within the register and auto populate the URN field with the same number. This is what I have done so far,

Option Compare Database
Option Explicit
Private Sub AttachPaymentDetails()
Call PerformInsert("tblFinancialBudget", "frmFinancialBudget")
End Sub

[code]....

View 5 Replies View Related

Forms :: Copy Value From Field In Subform To Field In Main Form During Data Entry

Jul 18, 2013

How can I get the value from a field in one table (in the sub form) to copy/insert into a field in another table (in the main form) when adding a new record?The main form and sub form are linked using parent/child linking, and the sub form is in a tab.I have table A (Visit Dates) in the main form which is used to record the date of a visit to a church. Table B (Quarters and Peals) is used to record an event that took place at that church during that visit. Note that not all visits in table A require a record to be created in table B - but half or more do.

In tables A and B I have a field called "QuarterOrPealID" and these are both primary keys, though the field in table B is set to 'no duplicates' and in table A it's set to 'duplicates allowed', as table A has its own auto number/pk. They are both linked in the relationships.

So, when I add a new record to table A using the main form, I might then need to click on the tab in the sub form to create a new record in table B, which has to be linked to the same record in table A. When the "QuarterOrPealID" auto number/pk is generated in the sub form (table B), I need that value to update to the "QuarterOrPealID" field of the main form (table A), so that when I'm viewing these records the form pulls all the information nicely together.

View 10 Replies View Related

Modules & VBA :: Hide Undo Button Until Data Entry On Form?

Mar 8, 2015

I have an Undo button : [btnUndo] and would like it hidden until someone starts to enter data, where it will become visible...

what code would I use? and where would

Code:
me.btnUndo.visible = true

be triggered?

View 3 Replies View Related

Modules & VBA :: Form Not Updated After Adding A Record

Oct 31, 2013

In one form, I have to click on button that opens the other form. Each form is bound to its table and those two tables are linked by Primary [RaDAR_Id] and Foreign [radar_id] fields. I would like the code to:

* open the other form
* move to the first record that has [radar_id] = [RaDAR_Is] if exists

If there is no any record in the other form that contains [radar_id] = [RaDAR_Id] then I want to create such record. So I am using the code (below). The problem is that the other form is not being updated.

Code:

Private Sub cmd_edit_usage_Click()
' DoCmd.OpenForm "frm_edit_usage"
Dim lngRadarId As Long
Dim patientId As Long
Dim rsUsage As DAO.Recordset
Dim rsUsageWrite As DAO.Recordset

[code]....

View 14 Replies View Related

Field Dependent On ComboBox For Data Entry Form

Mar 16, 2005

Hi,
I've got a data entry form where orders can be created. Within this form there is a ComboBox which is used to search for items and stores the selected item ID in the Order table. However the field for storing the Unit Price relating to the selected item is currently manually enterable. Where as I would like this to be dependent on the item selected within the ComboBox and updated automatically.

At the moment I've added an extra colum to the ComboBox to retrieve the relevant Unit Price and I can show this in a normal seperate text box using '=Combo27.Column(1)' as the ControlSource.

How can I get rid of the text box and incorporate the code into the current UnitPrice field so as it inserts the relevant record (price) into the UnitPrice coloumn of the Order table?

Any help on this would be much appreciated!

View 1 Replies View Related

Adding New Record To All Tables For 1 Table Primary Key Entry

Oct 20, 2006

Hi, I have 7 tables in my database and 1 form corresponding to all the fields in these tables (linked by a query by recordsource). My problem is that the form will only show a record if ALL 7 tables have manually had the primary key entered (not good when i have information that needs to be added at different times). How can I make it such that if I create a new record on the form that all primary key fields will be updated, and this record will be present every time i open my the form??

Cheers

Tania :o

View 2 Replies View Related

Creating Dynamic Hyperlinks - Open Data Entry Form And Navigate To Specific Record

Nov 28, 2011

I have a form that lists records in a table. I would like to have a hyperlink beside each record that will open the data entry form and navigate to that specific record. Right now, the use can only open the form for all records and has to use the record navigation buttons to find the desired record.

View 1 Replies View Related

How To Update A Field In Subform When Main Form Is Data Entry

Sep 19, 2012

I have a mainform set to data entry to add records to TABLE1. I inserted a subform that shows fields from TABLE2. I have a field in TABLE2, let's say TBL2FLD1(NUMBER). I want to add TBL1FLD2(NUMBER) from TABLE1 in the mainform to TBL2FLD1 and update said field in TABLE2.

My problem is:

(1) I get a #TYPE! error when I try to add the two fields, which I have tried many, many ways (adding them together in the Default Value; creating an unbound field to hold the calculation and then putting that field into the Default Value of TBL2FLD1; ETC), and
(2) I don't know how to get the subform to update TABLE2. It seems like the control gets stuck in the subform. Is there a way to accomplish this without coding it?

View 3 Replies View Related

Modules & VBA :: Adding Record To A Table - Closing A Form Without Saving

Nov 26, 2013

I have a form to add a record to a table. How can I give the user a way to close this form without saving the just created record.

I tried

If me.dirty then
DoCmd.RunCommand acCmdDeleteRecord
endif

This works, but gives a messagebox in return to confirm the command, and I don't want that. And I try to avoid sendkeys. I also don't want to change the options of access.

View 2 Replies View Related

Inserting A Record With A Date/time Field

Feb 2, 2005

Hi,

I'm trying to insert a record into an Access database from some ASP Code.

I have:

...
strSQL = "INSERT INTO tblUser (UserID, Date, Comments) VALUES " & _
(" & nID & ", #" & Now() & "#, " & "''" & strComments & "');"
conn.Execute(strSQL)
...

I'd have thought this should work but it doesn't.I just get a "Syntax error in INSERT INTO statement".

My date field, called "Date" (just in case that's a problem!) in my database has no input mask defined, it's just a basic date/time field. I've tried replacing the '#' symbols with single quotes, and doesn't work either. I haven't had any luck finding a definitive example of how to do this, even though it's trivial surely. All the similar examples I've found talk about how to update a record set with a date, or how to set the system locale, etc.

Any ideas as to what I might be doing wrong?

View 1 Replies View Related

Inserting Data Into A Field From A Query.

Oct 3, 2004

Hi,
Am currently working on a project for AS IT. one problem that i need to come across is trying to see data in a field that comes from a query?!?! Confused?! so am i!

When i first open the form, a paremeter query appears asking me to insert a surname (which i have created) when i insert the surname....and click on the drop down button, it gives me three values...ForeName, Surname and class

When clicking on the pupils name, i want the Class of the student to be inserted into the Class Field!

Can anybody help?
Danbwest

View 1 Replies View Related

Modules & VBA :: Ms Access Lock Table While Inserting Data

Oct 31, 2014

In a Access 2003 database, I have an "Inscriptions" (subscription) database with a primary key on 2 fields idPersonnel (employee) and idSession. I have made a form so that user can select a session (in a listbox), then one or more employee (another listbox) and suscribe them to that session by using a button, which, on VBA side, first check that there is enough room on the session (defined by "MaxParticipants" field on "Sessions" table, linked to "Inscriptions" table on idSession), then insert data in "Inscriptions" table

This is working fine in a single-user environnement, but fails if 2 people want to join some employees on the same session at the same time, as I have a confirmation message between check and insertion. Therefore 2 users can select employees, get the confirmation message (at this point both are told there is enough room), resulting in having more people than expected joined to the session. Fortuneatly, if both users try to insert the same employee(s) to that table, one will get a duplicate error, but insertion will be made if employees are different.

On another DB engine, such as SQL server, I would use a stored procedure that would lock the table, do the check and the insertion then unlock the table.

But it does not seem to be possible in MS Access. What are the possibilities in MS Access to prevent a session from having more than maximum number of participants ?

View 1 Replies View Related

Forms :: Adding Field To A Form Breaks Entire Database Record Source?

Sep 26, 2014

I am building a database where one Form displays records from 14 different tables. For some reason, when I recently try to add a field on to a form from a new table, the ENTIRE form loses the record source, and every single field that is already on the form gets that green dot in the corner with errors surrounding a record source that cannot be found. What am I doing wrong? Am I exceeding some limitations with forms?

View 4 Replies View Related

Getting The Autonumber Into The Form After Inserting New Record

May 14, 2005

I really hope I can explain this right :o

When a customer makes a purchase I INSERT the transaction into the 'transactions' table, which I have no problems with. My problem stems from that I can't seem to get the 'OrderNumber' back from the 'transaction' table (OrderNumber is an AutoNumber by the way).

I have tried the following code -
TempOrder = DLookup("OrderNumber", "transactions", "customerID = '" & Forms![frmOrder]!TempID & "'")
"Forms![frmOrder]!TempID" is the value I use from another form (to see who the customer is). I want "TempOrder" to be the OrderNumber that is created in the transactions table.

Regards, James

View 6 Replies View Related

General :: Save Record On Data Entry And Generate ID For That Record

Feb 1, 2014

I am working on a database and i have notice after making a form that when i enter a record using a form if i enter incomplete data on the form access automatically save that record and generate a id for that record.

For example I have a table that contain

StudentID,StdName,FatherName,DOB,Adress,Phone

And I have created a form for that table that also containing these fields.

Here I want to do that on the form I want a "Save" button , and the purpose of this button that when I click on this button then MS Access Save the record and then generate the ID for that record and if i close my form without pressing "SAVE" button access do not save that incomplete record.

View 10 Replies View Related

Modules & VBA :: Inserting Into Table From Form

Dec 29, 2013

I am building an application using MS ACCESS for a local volunteer ambulance corps and have almost complete it except for the last challenge. I have built many applications like this, with an form to add, modify and delete option for a single table. This time, the accountant asked for data to be saved before being deleted to another table so he can review it after it was deleted by a user and then delete it from that "backup" table. I am at a loss to write the code. However, being a reader of this forum taught me many things in the past and I decided to join and ask this query of the community. I know it is an insert command and I have created a mirror table for the real one with all of the twenty or so fields. The fields are the usual name, address, city state and zip with telephone numbers and some other info.

View 1 Replies View Related

Queries :: Check If Record Exists Before Inserting From Form?

Jul 2, 2014

The problem I have is, that I need to insert an apointment into de database but first I need to verify if there is a record or an apointment in that room that day the same hour, if that is so send a msgbox saying an apointment already exist in that room this day at this hour.

i tried using dlookup but it only works in one record using just one criteria

View 10 Replies View Related

Refresh Main Form After Inserting New Record In Another Form

Jan 24, 2012

I have a main form where information for a particular part number or job is entered. Should the part number not yet exist, Access will let you know. I have a button within the main form that opens up the Form_EnterPartNumber form which allows you to enter the new part number.

What I would hope to be able to do would be to refresh (requery?) the main form after creating a new part number and closing the Form_EnterPartNumber form..........but, keep the main form on the current record instead of resetting back to record number 1.

Is this possible?

View 1 Replies View Related

Inserting Data From Form Into Table

Nov 2, 2005

i have a problem adding the data from the fiels on the form into a table. I know you can just click on the navigation arrows and it will save the record but i want to use a submit button as this is more user-friendly and suitable for the work i'm doing.

I have attached the database... the form that needs the code for submit button is 'frmNew_JobStatus' and the table i'm trying to insert the data into is 'tblJobStatus'

can anybody have a look at what i've done so far and suggest how i can fix this... sample code would be very usefull as i'm not an access expert.

thank you all

View 1 Replies View Related

Inserting Data From One Table To Another Through Form

Aug 25, 2004

I want to design a form , please note I have beginners information regarding Access,
I have 2 tables , 1 table has Project No, Document No, DEpt NO. with all the information

There is another table-2 with Project No, Document No. and Resourcrce. There is not data
in this table

What I want to do is , I want to create a form where in I select the Project No. and
Dept No. When I select these items the form should list me the data in Table 1 for that
Project no and DEpt No. , after this data is listed , I will add the REsource data
and all this data has to be stored in table-2. I hope some one will be able to guide me on
how to do this.

View 6 Replies View Related







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