Manipulating Table Data From Code

Feb 12, 2005

I’m working on an Access 2002 project where I need some help with coding. I’m a neebie to Access and Visual basic so a few pointers to get me on my way would be much appreciated.

The project is dealing with logging vehicles on and off site. I have one database that contains a list of all regular traffic in three fields – Registration Number, Company Name and Type. After the last update this contained about 300 records. I called this MAINDATABASE.mdb.

I have another database that runs as a user input screen and front end called WORK.mdb. This contains the above three fields and three others, Time In, Number of Occupants and Time Out.

I have already done the coding for Time In and Time Out where the user just double clicks the field and the system time is entered. The important field is Registration Number. What I need is the following:

When a vehicle comes on site the user double-clicks Time In on the form which inserts the present time (done). The user then tabs to or clicks on Registration Number. An input box comes up where the user types the reg number. I need the code to take this input, search the MAINDATABASE database and if the reg number is found return the values for Registration Number,Company Name and Type in that row of the database and then insert those values into the corresponding rows in the WORK database. If the reg number isn’t found then a message box comes up telling the user to enter details manually and input the string entered by the user into Registration Number field on the WORK database and leave the user to enter the values for Company Name and Type. I have the code for the Input Box and the Message Box at the end!:


Private Sub REGISTRATION_GotFocus()

InputBox("Enter Reg number...")
……..

MsgBox "Registration number not found. Please enter details manually"

End Sub


I just need the stuff to do the work in between!!
Any pointers are very welcome……

View Replies


ADVERTISEMENT

Running Code When Data Changes In A Table

Oct 25, 2005

Hi

Ive made a booking system in Access and need to convert it so it can handle multiple users on a network. The problem i have is that when someone selects a block of time on one computer i need the other systems to lock out those blocks on their screens. I have a table which records each user's activities so i could always use the On Counter event on the form to repeatedly check if there is any blocks to be locked out according to data in that table. The obvious problem with this is the huge overhead.

Is there any other way round this? or is there any way of detecting changes to data in a table so that i can run code to lock out the blocks only when theres a change?

Any help or suggestions much appreciated! :)

View 1 Replies View Related

Forms :: VBA Code To Pull Data From Different Table?

Mar 26, 2015

I have a form I use for data entry, it needs to generate an id called RO Number and i need it be generated by access starting at number RO129036 and then keep adding sequentially, so RO129037 etc etc.

as i already have data in my DB that i need i cannot just reset any fields

having a table with just one field - the numeric part of the RO number so first one would be 129036 - so i need the form to pull this field, add 1, and then add "RO" at the beginning of it? i have really been struggling with this database

View 3 Replies View Related

Manipulating Calculated Fields

May 18, 2005

I developed a query that calulates when a contract is reviewed i.e 5 weeks and 9 weeks after the commencement date. These are called CDE1 and CDE2. This works well and the CDE1 and CDE2 dates are displayed ok.

The query above is:
SELECT Contract.ContractNo, Contract.APSNo, Contract.Firstname, Contract.Surname, Contract.AgencyDesc, Contract.FacilityName, Contract.Designation, Contract.WeeklyHrs, Contract.PositionNo, Contract.ComDate, Contract.EndDate, IIf(DateAdd("ww",5,[comdate])<[enddate],DateAdd("ww",5,[comdate])) AS 1stCDE, IIf(DateAdd("ww",9,[comdate])<[enddate],DateAdd("ww",9,[comdate])) AS 2ndCDE
FROM Contract;

The problem is that I now want to access contracts under these CDE dates between two dates that is user defined (startdate) and (enddate).

As the above are calculated fields, how can I develop a new query based on the above as CDE1 and CDE2 are already calculated fields?

View 2 Replies View Related

Manipulating ListWidth Problem

Sep 8, 2005

Hi all,

I have a problem manipulating the list width of a combobox. Now i set the list width property on the toolbar, as larger then the combobox for instance listwidth = 18.5cm while the combobox is about 10cm. Now i have a combobox that when clicked changes the property of the listwidth back to the size of the combobox. If the user clicks the combobox again it should return to 18.5cm but it does not seem to want to change back, even though all the other property changes work.


Here is my code:
Code:If label1.Visible = True Then Me.label1.Visible = False Me.label2.Visible = True If Me.label1.Visible = False Then Me.Combo.ColumnCount = 1 Me.Combo.ColumnHeads = False Me.Combo.ListWidth = 10 If label1.Visible = False Then Me.label1.Visible = True Me.label2.Visible = False If Me.label1.Visible = True Then Me.Combo.ListWidth = 18.503 'this does not work Me.Combo.ColumnCount = 10 Me.Combo.ColumnHeads = True End If End If End Ifend if

Where if label1.visible = true then listwidth = 18.5 else label2.visible = true listwidth = 10.

Thanks in advance for any help

M-.

View 4 Replies View Related

Manipulating List From Another Form

Nov 19, 2013

I have a button in formA. When I click on it I want it to show the listB.

(To show it I used the event code: ListB.Visible = True)

The thing is, listB is in formB (which is a subform of formA).

Code isn't working because listB doesn't exist in formA, got an error code.

I tried [Form]![FormB].ListB.Visible = True

But it didn't work, I don't think I can do this in an event code.

View 9 Replies View Related

Modules & VBA :: Code To Copy Partial Data To Another Form / Table

Jul 16, 2014

I have prepared a table in a database which includes a yes no box to one of the fields.

The idea of the yes/no field is that this is recording if the record is awarded. What i would like to achieve is that if the yes no box is checked "True" i would like to be able to copy some of the data from this table into a new table and that the form associated with this table opens up to enable the user to populate the remaining fields.

I believe i need to run this as an on click event procedure but cannot identify the code to enable the data to be copied accross to the other table.

View 14 Replies View Related

General :: Manipulating Dates Within A Form

Mar 2, 2013

I've been tasked to create a company client record database which permits several people at once to access and modify a communal database of clients. So far, so good. It's for a firm of solicitors, so I'd better get it RIGHT!!

One field requires the entry of a date, which the next field is supposed to automatically subtract 180 days from.

Is it possible for me to do this within the one entry form? The way I see it is that the first date would be entered, then the form would automatically display the -180 days result in the next box.

View 8 Replies View Related

Modules & VBA :: Code To Delete Table And Then Run 4 Append Queries To Refresh Data

Jun 11, 2014

I have a table called "EquipmentRequired" which is populated by 4 append queries,

5000BaseReq, 6000BaseReq, 6000IFBBReq, EquipmentReq which get some of their information by counting fields in another table but all have the same field names.

The queries contain all data that is initially used to append new records to the table and this works fine.Unless some information changes or a record is added then I would like to add a button to a form and call it "update equipment" behind which would run a vba code firstly to delete all the records in "EquipmentRequired" table then run the 4 queries without the warnings and re-populate the table.

View 9 Replies View Related

Forms :: Continuous Forms - Looping Through Records / Manipulating Fields On Form

May 29, 2015

I have a bound continuous tabular form,However, based on data content in one field of a record, I want a checkbox in the same record enabled, so the user can check it if necessary. I have created a record set using the form as shown below, and I am looping through each record. To show that my code is referring to the field with required data content, I display it as a message box and it works, yet my checkbox does not enable.

I have the code in the form_load event, however, for testing purposes I have it behind a button.If I am seeing this properly, the code behind the button enables the checkbox for ALL records once the criteria in the required field is true, and based on the last record, which has no data content, it disables the checkbox in ALL records. I also have the PK ID for each record hidden in the form. Can I utilize that to target the checkbox of each individual record??

Form Detail
-Form does not allow additions or deletions. Edits allowed
-All fields are disabled and locked
-I only want the check box to unlock if data is found in the "RequiredField" as referred to below. I have also tried if not isNull(requiredfield.value) then -enable checkbox, which yields the same results

Here is my code

Code:

Dim rstMyForm As DAO.Recordset
Set rstMyForm = Forms!MyForm.Form.Recordset
rstMyForm.MoveFirst
Do While Not rstMyForm.EOF
If Not RequiredField.Value = "" Then

[code]...

View 14 Replies View Related

How To Run Data Macro Using VBA Code

Jun 18, 2015

I try to run Data macro using VBA Code.

Code:
Private Sub cmdRunDataMacro_Click()
DoCmd.SetParameter "prmMetalID", Me.cmbMetal
DoCmd.RunDataMacro "Metal.GetMetalParameter"
DoCmd.SetProperty txtTestMetal, acPropertyValue, [ReturnVars]![retPrice]
End Sub

View 2 Replies View Related

Using External Data Wizard In Code

Jun 17, 2005

Hi all

I just to know what the command or code is to generate the External data wizard is ?
I want to import a spreadsheet, the thing this there will be a new spreadsheet everyday with a different name. I guess the easiest way is for the user to select the file themselves. instead of the user going to file, get external data, i thought i could add the code to invoke this wizard on a button.

Thanks in advance

View 1 Replies View Related

Code For Manual Data Entry

Sep 7, 2005

Can anyone tell me what code I can use to manually enter data from a textbox. I don't want a bound box, but want to write some code that will take the text from that text box and enter it into a field in a table when i wish it to.

How is this code written please?

Thanks

View 2 Replies View Related

Modify Data Structure Using Code

May 4, 2008

I want to be able to make code that will modify a data structure in another file. Can I do it in an access application or will I need to make a VB application? I want to add some more fields to a table. :confused:

View 1 Replies View Related

Turning Data Entry Off Through Code

Feb 23, 2006

Hi,

I have two main forms which are essentially the same apart from some command buttons, one form to enter data, one form to view data.

These forms also contain about 8 subforms, in Data Entry mode (for the data entry form, funnily enough).

Problem is, obviously when I open my form to view records, the subforms don't update as I flick through, due to them being in data entry.

What's the easiest way to prevent this problem? Obviously I'll need to turn data entry off, but was wondering whether there's a more elegant solution than either creating 8 duplicate subforms with data entry turned off, or using about 50 lines of code to turn Data Entry off/on every time.

Thanks,

Toby

View 1 Replies View Related

Using VBA Code To Import Tab Delimited Text Data

Oct 30, 2006

I have a table by name "newtab" and I was trying to import a tab delimited text file "newdata.txt" into newtab. The first line in the text file are the column names: SSN, Lastname, FirstName (all tab delimited though). The same field names exist in the destination file. However I am getting the error which says the "the field name SSN Lastname FirstName does not exist in the destination file" What could possibly be the problem? Since the field names are not separated in the error message, could it be that it is seeing all 3 field names as one and therefore cannot match them to the destination fields? Does that mean TAB cannot be used as the delimiter? Using the interactive IMPORT from access directly for the same files work really good though. However, I would like to do this programmatically since the files would be coming in weekly for me to load and they are many such files. The command I used is as below. Please I need help.

DoCmd.TransferText cImportDelim, , "newtab", "c:
eportsewdata.txt", True

View 1 Replies View Related

Charts - Controlling Data Range With Code

Jan 30, 2008

I have a nice chart that hasd done what I wanted it too.

Now I want to make the amount of X-AXIS data variable. Typically this would be 64 points. If you look at the datasheet, I can manually set the number of points by making sure the row selector is "raised".

Now that's say there is only 16 points of data to control. I can plot that those points but the chart is still 64 points wide with no data for points 17-64.

How can I, through code, prevent points 17-64 from plotting and thereby expand the graph horizontally larger and not display those null points?

I have tried a number of things including:
objDataSheet.Row(17).Delete
Graph_Data.Range("A1:A16:)
etc...

Nothing I have tried has worked. Is what I need to do possible?

Thanks much.

View 2 Replies View Related

Modules & VBA :: Code To Add Data In The Listbox That Meets Certain Criteria?

Jul 17, 2014

I have a Access table that stores BatchNo,Scandate,NewBatchNo . As I can't attach Access database here so I have exported data from Access to Excel in Sheet1 to show how the data is stored in Access table.

Now I have to write code in VBA that will check the last NewBatchNo in the table . In the attached workbook its 194389. Now vba code should check the NewBatchNo which are blank before 194389 . Now in the records where NewBatchNo is blank , it should add the corresponding BatchNo,ScanDate in the listbox1 in form1.

e.g Sheet2 in the attached workbook stores Bathcno and Scandate of those records where NewBatchNo is null and before the Last used NewBatchNo which is 194389 in our example.

View 4 Replies View Related

General :: Code Error When Load Data From Server

Jun 5, 2014

Im using ms access 2010 and this program compatible with previously ms access.the error show is type mismatch (error 13) on

Code:

Set rbs = CurrentDb.OpenRecordset("SELECT MSysObjects.Name" _
& " FROM MSysObjects WHERE MSysObjects.Type= 1 And MSysObjects.Flags=0" _
& " and MSysObjects.Name='" & n_tb & "'")

View 2 Replies View Related

Modules & VBA :: Reading Web Page Source Code Data?

Feb 13, 2014

Any method of reading web page source code data.

I am trying to create an event similar to a web query in Excel.

The table in question is not a html table but an asp.net table I think.

View 3 Replies View Related

General :: Code For Bringing Daily Data Into Excel

Jun 22, 2015

I am trying to transfer daily data that I get from three different queries all into one Excel sheet. I take it that you have to make one over-arching query which I have made called Awaiting Base.

View 4 Replies View Related

Split Data In A Column In Excel Via VBA Code In Access

Jun 6, 2012

I have an excel file I need to read and update a column in an access table. But the data I need is in a combined format like AA-000, BB-001 etc.

I need to separate the values AA, BB as one column and 000,001 as another column. How do I write code to accomplish this in a module in VBA.

So the tasks I need to do is:

read in the Excel file
split the data in a column in to two columns
update the already existing access table with the data in the two new columns.

View 2 Replies View Related

General :: Importing Excel Data To Listbox In Access VBA Code

Aug 9, 2013

Need importing just 1 column from excel file into vba !

View 1 Replies View Related

SQL Code To Create A Table

Jan 16, 2006

Hi,

a ER programm gives the following output to an sql code, which it pretends it should be for Access 97. Till now I haven't found an idea of how to create a table using the SQL statement CREATE. As a matter of fact it returns me an error of Create statement or something, even if I tried any available query form.

CREATE TABLE Algorithm_Property(
Algorithm_Property_ID Integer NOT NULL,
Layout_Property_Name_ID Integer NOT NULL,
Data_Type_ID Integer NOT NULL,
Submodel_Algorithm_ID Integer NOT NULL,
AlgPropValue Text(255) NOT NULL,
Global_User_ID Integer NOT NULL,
Row_Time_Stamp Integer NOT NULL
)
;
CREATE TABLE AppGenAttribute(
AppGenAttribute_ID Integer NOT NULL,
Attribute_ID Integer NOT NULL,
DiagramId Integer NOT NULL,
ModelId Integer NOT NULL,
EntityId Integer NOT NULL,
AttributeId Integer NOT NULL,
InitialValueType Text(1) NOT NULL,
ClientDefaultValue Text(254),
CounterColumn Text(1),
Global_User_ID Integer,
Row_Time_Stamp Integer
)
;

View 6 Replies View Related

Append To A Table Using Code

Oct 24, 2006

how to add records to an access table using code?

View 1 Replies View Related

Make Table With Code

Mar 24, 2007

i am sorry
im new using access
how can i make a table with code? and how can i create relationship between tables with using code?

View 1 Replies View Related







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