Modules & VBA :: How To Get Specific Value From Table Field

Jan 13, 2014

In my vba code i write this

If DLookup("Full_Name", "tbl_Personal_Information", "Full_Name = Forms!frm_New_Person!F_N") > 0 Then
'--------------------------
MSG = MsgBox("this client is existed and his id is {" & [P_ID] & "} ",
vbOKOnly + vbInformation + vbMsgBoxRtlReading, "client database")
Else
strsql101 = "insert into tbl_Personal_Information (Name_English, Father_English, Family_English, Mother_English,
P_ID, NName, Father, Family, Mother, Birthdate, Nationality, Record_Number, Record_Place, Address,

[Code] ....

My problem is the id in the msgbox give me the last id from tbl_personal_information

But what I want is the id of the client that i try to add...

View Replies


ADVERTISEMENT

Modules & VBA :: Update Specific Record In Table Using Unbound Field On Form

Dec 4, 2013

How to do an UPDATE using VBA on a form to update a specific record on the table using an unbound field on the form to filter the update.

Every time the code runs, it tells me: Run-time error '3144': Syntax error in UPDATE statement and takes me to the "CurrentDb.Execute strSQL, dbFailOnError" line at the end of my sample below.

Here's my code:

Dim strSQL As String
Dim strCriteria As String
strSQL = ""
strSQL = strSQL & " UPDATE [tblTicket] SET"
strSQL = strSQL & " ([UpdatedBy], [AssignedTo], [Requestor], [Dept])"
strSQL = strSQL & " Values"
strSQL = strSQL & " ('" & unbEnteredBy & "','" & cmbAssignedTo & "','" & cmbRequestor & "','" & cmbDepartment & "')"
strSQL = strSQL & "Where [tblTicket]![DateTimeOpened] = #" & FORMS!frmTicketTracker.unbDateTimeOpened & "#;"
CurrentDb.Execute strSQL, dbFailOnError

View 9 Replies View Related

Queries :: DSum - Update A Field In Specific Table With Info Form Another Table

Aug 5, 2014

I have a table products with a field "id_product" and "total" (Total items in stock)

I have a query with the fields "id_product" and also the field "total in stock"

I want an update query to update the field 'total' in table 'products' with infos from that query

For each id-product in table products, replace the field total with the field 'total in stock' from the query

So I want to update a filed in a specific table with infos form another table.

View 2 Replies View Related

Modules & VBA :: Edit Specific Row In Table

Dec 30, 2013

I have a report that I run which has PT_Ins_ID in it, I am trying to edit that row with the following code.

Code:
Private Sub cmd_Deact_Click()
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("dbo_Patient_Insurance")
If rs.RecordCount <> 0 Then
With rs

[code]....

I've also tried this.

Code:
Dim rs_PI As DAO.Recordset
Set rs_PI = CurrentDb.OpenRecordset("dbo_Patient_Insurance")

[code]...

View 6 Replies View Related

Sum Of Field From Specific Table

Aug 22, 2007

i have this form with 6 list box that output the data of a 6 tables.

*under each list box there is a text box that sum the field of their table.

i cant figure it out..

thanks

View 6 Replies View Related

Modules & VBA :: Open Table To Specific Record?

Oct 8, 2014

Is it possible to use VBA or macros to open a table to a specific record?

I know how to open a table in database view using a command button. I'd like to have it open to or automatically scroll to and select a specific record, based on the content of the form. This way I don't have to spend time scrolling through the whole table to try and find the desired record.

View 6 Replies View Related

Modules & VBA :: CASE Statement - Display Specific Text In A Field Based On Value Of Another

Sep 22, 2014

I have a lengthy CASE statement in my database that displays specific text in a field based on the value of another. Simple stuff but for some reason it randomly will not work on certain values, and never the same one twice. Is there a commonly known cause for this? I have verified that the spelling and spacing etc. are correct in my code so that shouldn't be causing the problem.

View 2 Replies View Related

Modules & VBA :: Export Table / Query To Specific Location

Jun 25, 2015

I am trying to export a query or table to a location that the user selects. So each time the export button is clicked the folder will change. But I want to be able to select the folder.

The code I have below is saving but not to the folder I want it to.

Private Sub CommandBtn_Click()
Dim fileSelection As Object
Dim strPath As String
Set fileSelection = Application.FileDialog(4)
With fileSelection
.AllowMultiSelect = False
If .Show = True Then

[Code] ....

View 1 Replies View Related

Modules & VBA :: Convert Table To Specific Text Format

Feb 17, 2014

I have a problem in converting the content of a simple table to a text format I need for an other program. The table is containing 3 columns

- ITEMID
- COLOR
- MINQTY

How do I convert the table to a text format with below format.?

ITEMTYPE is all ways >P<

How is this text shown. Do I make a kind of report.?

I have attached the two document (Text format and DB)

<INVENTORY>
<ITEM>
<ITEMTYPE>P</ITEMTYPE>
<ITEMID>3622</ITEMID>
<COLOR>11</COLOR>
<MINQTY>20</MINQTY>

[Code] .....

View 1 Replies View Related

Modules & VBA :: Receive Email When A Row Added To Specific Table?

Oct 8, 2013

Is it possible to receive an email when a row added to a specific table?

View 3 Replies View Related

Select Specific Sectors From Table Field

Nov 14, 2005

Hi

I need to select from a table field of upto 50 characters: the first 15 characters and then the remaining charachters (i.e. after 15...)

I would much apreciate some help...

Thanx

View 9 Replies View Related

Modules & VBA :: Load Specific Email Items To Access Table

Jul 8, 2014

In my Access app, I need to be able to retrieve a specific email by date/time, then take the Subject, the Date received and body of that email and save it to a column in a table.how to do this in Access VBA?

View 1 Replies View Related

Modules & VBA :: Search CSV To Find Specific Statement / Text On Specific Line?

Jul 8, 2015

how to read a specific line in a CSV file (using VBA), to see if the phrase "There are no records available." is present.

If it is present, then I'm going to do a debug.print stating that there are no records to load - and then the script will move on to the next file. If the phrase isn't present, then I'm going to upload the file to Access, parse the information, and then upload it to a CRM. (I already have the latter portion of the code up and running....I just need to account for the first part, where I can determine if the file has data or not).

The structure of the file never changes. The first row is composed of eight column headers (Post Date, Card Number, Card Type, Auth Date, Batch Date, Reference Number, Reason, Amount) and (if) the phrase "There are no records available." is present, it will show up on the second row, in the first column (under Post Date).

View 3 Replies View Related

Insert New Field With Specific Data Type In The Table?

Apr 24, 2014

i wanna to insert a new field in the table ... which fill automatically with the date in which i modified the data in this record ...and then i'll insert this field in a report

View 1 Replies View Related

Modules & VBA :: Using Temp Variable To Append Specific Number Of Records To Table

May 29, 2014

I need to extract a specific number of records into a table using a MakeTable or Append command using a temp variable, e.g. TempK&SA. Previously on the forum I was shown how code could be added to the OnOpen function to use a temp variable to select a specific number of records to report. ACCESS does not have the OnOpen function in the design view of a query like in the report. It does allow a SELECT TOP but only with fixed variables or percents (e.g. 25 in the code below).

The beginning code for the make table query (where 25 is the number of records added) is:

INSERT INTO [Output] ( RndNo, PointBiserial, BloomsTax, DateRevised, Exam1, Status, Exam2, Exam3, Exam4, [NCCPAKnowledge&Skills] )
SELECT TOP 25 TestBank.RndNo, TestBank.PointBiserial, TestBank.BloomsTax, TestBank.DateRevised, TestBank.Exam1, TestBank.Status, TestBank.Exam2, TestBank.Exam3, TestBank.Exam4, TestBank.[NCCPAKnowledge&Skills], *
FROM TestBank
WHERE (((TestBank.PointBiserial) Is Null Or (TestBank.PointBiserial) Between [TempVars]![TempPointBiserialLow] And .....

how to modify the code to allow a temp variable to determine the number of records to append to another table would be gratefully received. (This process then is repeated for a total of 7 append tables with different temp variables.)

View 7 Replies View Related

Make Specific Field To Be Sum Of Many Other Fields In Design Table Without Using Codes

Apr 26, 2014

how can i make a specific field to be a sum of many other Fields in design table with out using codes

View 1 Replies View Related

Modules & VBA :: Copy Excel File Or A Table In Access To Specific Location On FTP Server

Jul 11, 2013

I need some simple code that will copy an Excel file or a table in Access to a specific location on an FTP server. I would think this would be a very simple task, but I have yet to find any sample code that is *simple*. I have seen lots of code that requires downloading this dll or that mda, but the examples don't work. There must be something built into MS Access 2010 that will allow a file to be uploaded to an FTP site.

All the variables are known:

The FTP location (it never changes)
The FTP Username and Password (they never change)
The destination folder on the FTP site (it never changes)
The File type (it never changes)
The File name (available from the form in Access from which this will be executed)

I can either produce an output file, then copy it to the FTP site, or I can export the table directly to the FTP site with the file name for that day.

This seems to be a very simple task with no simple solution. Currently I am using an FTP app to get the file to the FTP site, but I would like to automate this. The process that creates the output file is already automated, so I would just like to add this to the existing code as its own module.

I'm looking for a simple command on the idea of:

DoCmd.FTPFile, acExel, TableName, FTPFilePath, FTPFileName, Username, Password, acUpload

just made all that above up and none of it is a real function/command in VBA, but is just the kind of thing I'm looking for.

I would think that since I can download and XML file from an FTP site that it should be child's play to upload a simple file to an FTP site, but I can't figure it out.

View 8 Replies View Related

How To Populate Data Field With Specific Date To Existing Table In Access 2010

Jun 14, 2013

I have a table with more than a million records. I want to add a new column with date equals to e.g.3/14/2012 for all the records. I am using update query, but it is super slow (taking more than a hour)..is there any other way to do this?

View 6 Replies View Related

Locking A Specific Field Of A Specific Record

Oct 3, 2005

Hello, I have just spent ages doing searches and reading everything I can on locking. But, I have yet to find an answer as to how I can lock a specific field in a specific record.

e.g. Staff enter customer details, then at the end of the day the admin (me) checks it over and presses a big old button that stops them from locking certain fields in the current record only - they must still have access to the unlocked fields of the current record, and it must not lock any other records.

I'm guessing there's some VB code in the form of fieldname.lock = true, but then it locks the field throughout the whole table!

Can anyone tell me how to do this please?

View 11 Replies View Related

Modules & VBA :: Code To Check Contents Of A Field In A Table Where Another Field

Sep 11, 2013

I am trying create some code that checks if the contents of the status field in a table is "Authorised" where the ID = something specific for multiple records. If all records witht the specific ID are "Authorised" Then generate a new record in another table. Where to start, perhaps a Dlookup?

View 1 Replies View Related

Modules & VBA :: Updating A Field In A Form Based On Another Table Field

Sep 13, 2013

Using Access 2010. Fairly new to automation and macros.I have two tables (tblProductReceived and tblBins) and a form (frmProductReceived).A field in tblBins corresponds to a location the bin is at (named BinLocationID) and the tblProductReceived table tracks product that a specific bin has received.

What I need is for the tblProductReceived field PRLocationID ([tblProductReceived].[PRLocationID]) to be automatically populated with where the bin is at ([tblBins].[BinLocationID]) when selecting a specific bin in the form (frmProductReceived).

View 1 Replies View Related

Modules & VBA :: Restrict Value In Lookup Field To Only Include Values From Table B Not In Table A?

Feb 2, 2014

I have a database that has 2 tables. Table A and Table B. Table A is my primary table. On this table I have 2 fields. The first field is a LOOKUP Field that looks up information from Table B and displays my selection in the field on Table A. Then using DLOOKUP I automatically input the information in the Second Field on Table A based upon the selection from the First Field.

This is working mostly correctly. However, the problem is, when I click on the next record in the table, it automatically changes the Second Field on that record to the same value as the record before it and continues this trend each time I click on another record. This occurs without me making a selection in the first field. If I make a selection in the first field it does change the Second Field to the Correct Value, but then the next Record has the same issue.

How do I go about fixing this so it doesn't change the value with the change of the record. Only change if I change that particular field within that 1 record?is there a way to restrict the Value's in my lookup field to only include the Values from Table B that aren't already in Table A?

View 5 Replies View Related

Modules & VBA :: Add New Field In Every Table (100 Tables)

Apr 16, 2015

I inherited an old database. Not designed too well. Nearly 100 tables with different types of names. Some table names start with and "_", some with "tbl" and some just names.

I want to add a new field called "TimeStamp", date/time, and default value Now() to all the tables.

View 5 Replies View Related

Modules & VBA :: Create Table Yes / No Field

Aug 26, 2014

I have the following vba script and I can not get the yes/no field to work, also with adding field properties of required = yes and the text field to be 50, just examples are fine and I will update what I want.

Code:

Sub test()
Set Db = Application.CurrentDb
Set tdf = Db.TableDefs("1Testing") ' 1Testing is your table name
' First create a field with data type = Text
Set fld1 = tdf.CreateField("FieldT1", dbText) ' Field1 is your Field Name and formatted as text

[Code] ....

View 1 Replies View Related

Modules & VBA :: Using Where Clause To Max Of A Table Field

Sep 18, 2014

I am trying to open a form using the where clause to max of a table field.I cannot get the syntax correct.

Code:

DoCmd.OpenForm "frmInput", , , Max(tblClients.ClientID) AS MaxOfClientID FROM tblClients

View 4 Replies View Related

Modules & VBA :: Copy Field1 To Field 2 In Table

Feb 20, 2015

I want to save the timestamp created in a table when a user opens the database. My vba saves the computer name and user name and sets the currentuser = yes. The table is mysql odbc, and has the requisite timestamp and id fields. I have a form that I can open that shows who is online at that moment. When a user closes the database, the currentuser field is set =no. All of that works well. Now, I have added a "starttime" field in which I would like to store the timestamp that was set upon opening, since when a user logs off, the timestamp gets changed to the log off time.

Code:

Dim myQry As String
Dim sUserName As String
Dim sUserComputer As String
Dim currentVersion As Date

[code]....

The UserTimestamp in red is the field value of the first record in the table, not the usertimestamp in the user's record. How do I store the log on timestamp in the "starttime" field?

View 1 Replies View Related







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