Can following query be used to find inserted update records.

hi,
i am using query1) to insert data query2) to update the record
query1)
INSERT INTO [t1]
           ( id
            ,createddatetime
           ,updateddatetime)
     VALUES
           (1
           ,GETDATE()
           ,GETDATE()) 
query2)
update t1 set updatedatetime=getdate() where id=@t1
please tel me will two date cols get same time , that is, will i be able to 
write following to find inserted/updated rows
if exists(select * from t1 where createddt1=updateddt2)
begin 
select 'inserted'
end 
else
begin 
select 'updated'
end
yours sincerely

Depending on how you execute both the queries there's a small chance date value comparison may not wok as expected as datetime also has timepart until milliseconds precision. So if you want to retrieve details on records inserted and updated you may use
something like below
query 1
DECLARE @dt datetime
SET @dt = GETDATE()
INSERT INTO [t1]
( id
,createddatetime
,updateddatetime)
VALUES
(1
,@dt
,@dt)
query2
DECLARE @dt datetime
SET @dt = GETDATE()
update t1 set updatedatetime=@dt where id=@t1
then you can do below to get inserted updated detailsif exists(select * from t1 where createddt1=updateddt2)begin select 'inserted'end elsebegin select 'updated'end
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • Can I rewrite the following query without using Row_number() function ??!!

    Hello every one, can I rewrite the following query without using the 'ROW_NUMBER() OVER ' part.
    The query is supposed to pull out the records whose CODE is not NULL and has most
    recent date for UPDATE_DATE . The reason I wanted to do this is, When I embed this query
    in between many other queries along with JOINs, My oracle server is unable to execute. So, I thought
    its better to supplant 'ROW_NUMBER() OVER ' logic with something else and try it. .
    SELECT a.* FROM
    (SELECT b.*, ROW_NUMBER() OVER (PARTITION BY b.PIDM
    ORDER BY b.UPDATE_DATE DESC) AS Rno
    FROM
    SELECT *
    FROM SHYNCRO WHERE CODE IS NOT NULL
    )b
    )a
    WHERE a.Rno = 1

    Hi,
    You didn't write over 150 lines of code and then start testing it, did you?
    Don't.
    Take baby steps. Write as little as pssiblem test that. Debug and test again until you have something that does exactly what you want it to do.
    When you have somehting that works perfectly, take one baby step. Add a tiny amount of code, maybe 1 or 2 lines more, and test again.
    When you do get an error, or wrong results, you'll have a much better idea of where the problem is. also, you won't be building code on a flimsy foundation.
    If you need help, post the last working version and the new version with the error. Explain what you're trying to do in the new version.
    The error message indicates line 133. It looks like line 133 of your code is blank. Does your front end allow completely blank lines in the middle of a query? SQL*Plus doesn't by default; you have to say
    SET  SQLBLANKLINES  ONto have a completely blank line in SQL*Plus. (However, lines containing nothing but at commnet are always allowed.)
    You may have noticed that this site normally doesn't display multiple spaces in a row.
    Whenever you post formatted text (such as indented code) on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    The 4 people who posted small code fragments for you to read all did this.  It would be so much easier for people to read your humongeous query if it were formatted.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can u write the following query without using group by clause

    select sp.sid, p.pid, p.name from product p, supp_prod sp
    where sp.pid= p.pid and
    sp.sid = ( select sid from supp_prod group by sid
    having count(*) =(select count(*) from product));
    thru this, we retrieving all the products delivered by the supplier.
    Can you write the following query without using the group by clause

      select sp.sid, p.pid, p.name
        from product p, supp_prod sp
       where sp.pid= p.pid the above query will still retrieve all the products supplied by the supplier. sub-query is not necessary.
    maybe if you can post some sample data and output will help us understand what you want to achieve.

  • I share an Apple ID with my family can we still all use the find my friends app or do we need our own Apple ID's?

    I share an Apple ID with my family...can we still all use the find my friends app or do we need to get our own Apple ID's?

    To avoid confusion and merging data... it's always suggested that each person have their own apple id.

  • Can I run a Unix shell when insert some record on a specific table?

    Can I run a Unix shell when insert some record on a specific table?
    I need to run a Unix shell when a record be insert on a table. Is there a way in order to do that?
    THanks,
    Carlos.

    1. Make a backup of the extproc.c file in the c:\orant\rdbms80\extproc
    directory.
    2. Create a file called extern.c in the c:\orant\rdbms80\extproc directory.
    The "extern.c" file :
    #include <oci.h>
    #define NullValue -1
    #include<stdio.h>
    #include<string.h>
    long __declspec(dllexport) OutputString(context ,
                             path , path_ind ,
                             message , message_ind,
                             filemode , filemode_ind ,
                             len , len_ind )
    char *path;
    char *message; 
    char *filemode;
    int len;
    OCIExtProcContext *context;
    short path_ind;
    short message_ind;
    short filemode_ind;
    short len_ind;
    FILE *file_handle;
    int i ;
    char str[3];
    int value;
    /* Check whether any parameter passing is null */
    if (path_ind == OCI_IND_NULL || message_ind == OCI_IND_NULL ||
    filemode_ind == OCI_IND_NULL || len_ind == OCI_IND_NULL ) {
    text initial_msg = (text )"One of the Parameters Has a Null Value!!! ";
    text *error_msg;
    /* Allocate space for the error message text, and set it up.
    We do not have to free this memory - PL/SQL will do that automatically. */
    error_msg = OCIExtProcAllocCallMemory(context,
    strlen(path) + strlen(initial_msg) + 1);
    strcpy((char *)error_msg, (char *)initial_msg);
    /*strcat((char *)error_msg, path); */
    OCIExtProcRaiseExcpWithMsg(context, 20001, error_msg, 0);
    /* OCIExtProcRaiseExcp(context, 6502); */
    return 0;
    /* Open the file for writing. */
    file_handle = fopen(path, filemode);
    /* Check for success. If not, raise an error. */
    if (!file_handle) {
    text initial_msg = (text )"Cannot Create file ";
    text *error_msg ;
    /* Allocate space for the error message text, and set it up.
    We do not have to free this memory - PL/SQL will do that automatically. */
    error_msg = OCIExtProcAllocCallMemory(context,
    strlen(path) + strlen(initial_msg) + 1);
    strcpy((char *)error_msg, (char *)initial_msg);
    strcat((char *)error_msg, path);
    OCIExtProcRaiseExcpWithMsg(context, 20001, error_msg, 0);
    return 0;
    i = 0;
    while (i < len)
    /* Read the hexadecimal value(1). */
    str[0] = message;
         i++;
    /* Read the hexadecimal value(2). */
    str[1] = message[i];
    /* Convert the first byte to the binary value. */
    if (str[0] > 64 && str[0] < 71)
    str[0] = str[0] - 55;
    else
    str[0] = str[0] - 48;
    /* Convert the second byte to the binary value. */
    if (str[1] > 64 && str[1] < 71)
    str[1] = str[1] - 55;
    else
    str[1] = str[1] - 48;
    /* Convert the hex value to binary (first & second byte). */
    value = str[0] * 16 + str[1];
    /* Write the binary data to the binary file. */
    fprintf(file_handle,"%c",value);
              i++;
    /* Output the string followed by a newline. */
    /* fwrite(message,len,1,file_handle); */
    /* Close the file. */
    fclose(file_handle);
    3. Use the make.bat available in the c:\orant\rdbms80\extproc directory. You
    need to run vcvars32.bat file before running this batch file. This will
    create a dll file.
    4. Configure the tnsnames.ora and the listener.ora files.
    The tnsnames.ora should contain the following entries.
    extproc_connection_data.world =
    (DESCRIPTION =
    (ADDRESS =
    (PROTOCOL = IPC)
    (KEY = ORCL)
    (CONNECT_DATA = (SID = extproc)
    The listener.ora should contain the following entries.
    # P:\ORANT\NET80\ADMIN\LISTENER.ORA Configuration File:p:\orant\net80\admin\listener.ora
    # Generated by Oracle Net8 Assistant
    LISTENER8 =
    (ADDRESS = (PROTOCOL = TCP)(HOST = winnt_nsc)(PORT = 1521))
    SID_LIST_LISTENER8=
    (SID_LIST =
    (SID_DESC =
    (GLOBAL_DBNAME = winnt_nsc)
    (SID_NAME = ORCL)
    (SID_DESC =
    (SID_NAME = extproc)
    (PROGRAM = extproc)
    5. Login from sqlplus and issue the following statements.
    create library externProcedures as 'C:\orant\RDBMS80\EXTPROC\extern.dll';
    Create or replace PROCEDURE OutputString(
    p_Path IN VARCHAR2,
    p_Message IN VARCHAR2,
    p_mode in VARCHAR2,
    p_NumLines IN BINARY_INTEGER) AS EXTERNAL
    LIBRARY externProcedures
    NAME "OutputString"
    With context
    PARAMETERS (CONTEXT,
    p_Path STRING,
    p_path INDICATOR,
    p_Message STRING,
    p_message INDICATOR,
    p_mode STRING,
    p_mode INDICATOR,
    p_NumLines INT,
    p_numlines INDICATOR);
    This is the pl/sql block used to write the contents of the BLOB into a file.
    Set serveroutput on before running it.
    SQL> desc lob_tab;
    Name Null? Type
    C1 NUMBER
    C2 BLOB
    lob_tab is the table which contains the blob data.
    declare
    i1 blob;
    len number;
    my_vr raw(10000);
    i2 number;
    i3 number := 10000;
    begin
    -- get the blob locator
    SELECT c2 INTO i1 FROM lob_tab WHERE c1 = 2;
    -- find the length of the blob column
    len := DBMS_LOB.GETLENGTH(i1);
    dbms_output.put_line('Length of the Column : ' || to_char(len));
    -- Read 10000 bytes at a time
    i2 := 1;
    if len < 10000 then
    -- If the col length is < 10000
    DBMS_LOB.READ(i1,len,i2,my_vr);
    outputstring('p:\bfiles\ravi.bmp',rawtohex(my_vr),'wb',2*len);
    -- You have to convert the data to rawtohex format. Directly sending the buffer
    -- data will not work
    -- That is the reason why we are sending the length as the double the size of the data read
    dbms_output.put_line('Read ' || to_char(len) || 'Bytes');
    else
    -- If the col length is > 10000
    DBMS_LOB.READ(i1,i3,i2,my_vr);
    outputstring('p:\bfiles\ravi.bmp',rawtohex(my_vr),'wb',2*i3);
    dbms_output.put_line('Read ' || to_char(i3) || ' Bytes ');
    end if;
    i2 := i2 + 10000;
    while (i2 < len ) loop
    -- loop till entire data is fetched
    DBMS_LOB.READ(i1,i3,i2,my_vr);
    dbms_output.put_line('Read ' || to_char(i3+i2-1) || ' Bytes ');
    outputstring('p:\bfiles\ravi.bmp',rawtohex(my_vr),'ab',2*i3);
    i2 := i2 + 10000 ;
    end loop;
    end;

  • What mechanism Oracle 10g use for write (Insert/ Update) and Read (Select)?

    Hi
    What mechanism Oracle 10g use for write (Insert/ Update) and Read (Select)?
    Thank you

    Aren't the answers given in PL/SQL forum sufficient enough?Well, as the first answer in that forum directed the OP to this forum you can hardly blame them for the repost.
    There is some high-level stuff in the Concepts Guide. If that is insufficient the OP will need to tell us what more details they need to know (and perhaps why).
    Cheers, APC

  • Insert/Update Record - Server Behavior

    Help Please!
    I have several pages with forms that insert records, but I
    over the weekend when I went to open them from the web to
    insert/update records errors appeared. They were working fine
    before. Using PHP, MYSQL and Dreamweaver CS3
    I have tried everything I know to do. I have recreated the
    page, same problem as well as delete behaviors and reapply them.
    Once the server behavior is added it no longer says Insert
    Record in the Application window instead it says "Dynamic
    Attribute" Further, when I click it to make any changes etc,
    instead of the screen for Insert or Update record coming up it is a
    "Dynamic Text box" regarding POST or GET or URL stuff.
    Edited to add: And once posted, the page only shows an error
    and references this line
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    Error Message
    Parse error: syntax error, unexpected '<' on line 40
    What can I do?

    You don't say which server-side language you're using, but the way that I would troubleshoot this in PHP is to use echo to display the value of $_SESSION['MM_Username'] at the bottom of the admin page. This is the session variable Dreamweaver uses to control access to a page with username and password. If the value is displayed, it means sessions are working, and the variable hasn't been destroyed.
    If that works, move onto the next page, and use echo to display the value of $_SESSION['MM_Username'] as soon as the session has been started. To prevent being redirected to the fail page, temporarily comment out the following line:
    header("Location: ". $MM_restrictGoTo);
    Basically, you need to check what's happening to the session variable that controls access to the pages.

  • Can you use ESB to insert multiple records into a Database

    We have an XML file that has a Parent/Child relationship.
    In situation 1 we have a single parent record in the xml file. We can insert the record into the database successfully.
    In situation 2 we have a parent and a an associated child record. By using a filter expression to identify the existence of the child record we can route to the first DB Adapter to insert the parent then to the second DB Adapter to insert the child.
    Is this final scenario logical and also possible.
    Situation 3 we have multiple child records associated to a single parent. So we would first insert the parent record then insert all the child records.
    Thanks

    I use PL/SQL for this if you are using Oracle.
    Have a look at this post, it is for AQ but the concept can be used for PL/SQL
    Re: Can I pass a pl/sql table as a parameter from a database adaptor
    I will send you an example
    cheers
    James

  • Business Catalyst Problem Using API to insert/update

    Hi,
    I am trying to use the API to insert/update products. But have been getting the following error in the response.
    HTTP/1.1 100 Continue
    HTTP/1.1 500 Internal Server Error
    Cache-Control: private
    Content-Length: 370
    Content-Type: text/xml; charset=utf-8
    Server: Microsoft-IIS/7.0
    Date: Tue, 05 Jun 2012 22:11:39 GMT
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <soap:Body>
            <soap:Fault>
                <faultcode>Error</faultcode>
                <faultstring>ERROR: A server error has occured.</faultstring>
                <detail />
            </soap:Fault>
        </soap:Body>
    </soap:Envelope>
    I have looked through my request and cant see anything wrong so was wondering if anyone else can, or if there is something I have missed (or not setup properly), i'm sure its probably an obviously mistake that i just cant find. below is my request
    POST /CatalystWebService/CatalystEcommerceWebservice.asmx HTTP/1.0
    Host: {HOST}.worldsecuresystems.com
    User-Agent: NuSOAP/0.9.5 (1.123)
    Content-Type: text/xml; charset=UTF-8
    SOAPAction: "http://tempuri.org/CatalystDeveloperService/CatalystEcommerceWebservice/Product_UpdateInsert"
    Content-Length: 1525
    <?xml version="1.0" encoding="UTF-8"?>
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns9872="http://tempuri.org">
        <SOAP-ENV:Body>
            <Product_UpdateInsert xmlns="http://tempuri.org/CatalystDeveloperService/CatalystEcommerceWebservice">
                <username>{USER}</username>
                <password>{PASSWORD}</password>
                <siteId>{SITEID}</siteId>
                <productList>
                    <Products>
                        <productId>1</productId>
                        <productCode>test1</productCode>
                        <description>test desc</description>
                        <smallImage>/images/test_small.jpg</smallImage>
                        <largeImage>/images/test.jpg</largeImage>
                        <cataloguesArray>
                            <string>Products</string>
                        </cataloguesArray>
                        <pricesSaleArray>
                            <string>GB/9.99</string>
                        </pricesSaleArray>
                        <pricesRetailArray>
                            <string>GB/18.99</string>
                        </pricesRetailArray>
                        <supplierEntityId>-1</supplierEntityId>
                        <minUnits>-1</minUnits>
                        <maxUnits>-1</maxUnits>
                        <inStock>2</inStock>
                        <onOrder>-1</onOrder>
                        <reOrder>-1</reOrder>
                        <inventoryControl>false</inventoryControl>
                        <enabled>false</enabled>
                        <deleted>false</deleted>
                        <downloadLimitCount>-1</downloadLimitCount>
                        <limitDownloadsToIP>-1</limitDownloadsToIP>
                        <isOnSale>false</isOnSale>
                        <productWeight>-1</productWeight>
                        <productWidth>-1</productWidth>
                        <productHeight>-1</productHeight>
                        <productDepth>-1</productDepth>
                        <cycletypeId>0</cycletypeId>
                    </Products>
                </productList>
            </Product_UpdateInsert>
        </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    Many Thanks
    Tim

    I am successfully doing API Product Updates, not tried Creates yet.
    From the WSDL you need theses fields;
    'supplierCommission' => 0,      // type="s:double"/>
    'weight'             => 2,      // type="s:int"/>
    'inventoryControl'   => false,  //  type="s:boolean"/>
    'canPreOrder'        => false,  //  type="s:boolean"/>  'captureDetails'     => false,  //  type="s:boolean"/>              
    'isOnSale'           => true,   //  type="s:boolean"/>              
    'hideIfNoStock'      => false,  //  type="s:boolean"/>              
    'isGiftVoucher'      => false,  //  type="s:boolean"/>              
    'enableDropShipping' => false,  //  type="s:boolean"/>              
    excludeFromSearch'  => false,  //  type="s:boolean"/>              
    'cycletypeCount'     => -1,     //  type="s:int"/>
    + the other arrays or the update wipes out data.
    Experimentation seems to be the key

  • How to find insert,update on schema

    Hi,
    I want to monitor insert,update or delete perform onparticular schema of the database .
    your early repsone is appriciated.
    Thanks in advance.

    user647572 wrote:
    Thanks for your kind response .. it is very useful to me ...
    sorry but i am using below query and
    EXTENDED_TIMESTAMP as timestamp with timezone data type...
    SELECT SQL_TEXT
    FROM
    DBA_COMMON_AUDIT_TRAIL
    where EXTENDED_TIMESTAMP between to_date('20101016 10:30', 'yyyymmdd hh24:mi')
    and to_date('20101016 11:00', 'yyyymmdd hh24:mi')
    AND OBJECT_SCHEMA = 'JISPBILCORBILLINGPRD501'
    AND UPPER(SQL_TEXT) LIKE UPPER('INSERT%')
    it is taking more time to display result.
    This is normal situation.Check sys.aud$ table,how much record contain this table?
    You can delete old audit records as
    DELETE FROM sys.aud$ WHERE timestamp# < SYSDATE -40;>
    Please give me suggestion on it..

  • Can a query make use of an Index on concat column ?

    Hi sql gurus,
    We will develope application on a database as below ( simplified ) :
    create table invoice (doc_no varchar2(30), cust_code varchar2(10), amount number (12,2));
    create table debit_memo (doc_code varchar2(6), doc_no varchar2(24), cust_code varchar2(10), amount number (12,2));
    create table credit_memo (doc_code varchar2(6), doc_no varchar2(24), cust_code varchar2(10), amount number (12,2));
    create view v_ar_transaction as
    select doc_no, cust_code, amount from invoice
    union
    select doc_code||doc_no, cust_code, amount from debit_memo
    union
    select doc_code||doc_no, cust_code, amount from credit_memo
    The question is :
    If I have query like this :
    select * from v_ar_transaction where doc_no = :pdoc_no
    Can it use the index built on the tables ?
    What kind of index that will help the above query to be efficient ?
    Thank you for your help,
    xtanto

    create view v_ar_transaction as
    select doc_no, cust_code, amount from invoice
    union
    select doc_code||doc_no, cust_code, amount from
    debit_memo
    union
    select doc_code||doc_no, cust_code, amount from
    credit_memo
    he question is :
    If I have query like this :
    select * from v_ar_transaction where doc_no =
    :pdoc_no
    an it use the index built on the tables ?
    What kind of index that will help the above query to
    be efficient ?I'd try:
    doc_no for invoice
    function based index doc_code||doc_no for debit_memo and credit_memo
    As a side note - do you really need UNION or UNION ALL?
    Isn't important where the transaction comes from?
    Gints Plivna
    http://www.gplivna.eu

  • Can I query WMI using Data Collection Form ZCM 11 Sp2

    I'm very new to ZenWorks and I'm trying to query WMI from the Data Collection Form in an admin defined field.
    I read somewhere that you can query WMI in a similar fashion to querying a registry key but not getting results.
    Any help would really be appreciated.
    Thanks.

    robmetcalfe,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Visit http://support.novell.com and search the knowledgebase and/or check all
    the other self support options and support programs available.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://forums.novell.com)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://forums.novell.com/faq.php
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://forums.novell.com/

  • HT4623 Following our first use of FaceTime after updating our iPhone 4s, our App Store went blank and is no longer functional.  How can this be rectified?  Thanks.

    We used Face Time last night for the first time after updating our phones recently to IOS 6; then discovered our App Store is empty of all apps and is no longer functional.  How can this be fixed?
    Thanks

    We used Face Time last night for the first time after updating our phones recently to IOS 6; then discovered our App Store is empty of all apps and is no longer functional.  How can this be fixed?
    Thanks

  • Can not open download folder in Finder after update to OS X Lion

    Hi there. I have recently upgraded to OS X Lion. The upgrade was smooth. But since the upgrade I am unable to open Download folder in Finder. If I select Download in Finder's sidebar nothing happens. Finder won't display content of Download folder. If I go and select Home folder in sidebar, Finder displays content of my Home folder including Download. If I double click Download folder to access it nothing happens again. Cant access it. But if expand download folder using triangle next to it, Finder will expand me Download folder and show it's content...
    I tried to verify and repair my permissions with Disk Utility, but did not solve my issuel. It is very frustrating scenario, since Download folder is something I access every day multiple times.
    Any ides what can I do?

    I found a solution that worked for me. Seems like my firewall did not accept the afp connection permissions anymore after installing lion... Since everything worked well turning off the firewall.
    So if you don't want to keep your firewall disactivated here is what worked for me:
    - Leave your firewall activated.
    - Turn OFF afp file sharing in the sistem prefs
    - Restart your Machine
    - Turn ON afp file sharing
    - You should now get a message if you want to accept afp connections...
    - click YES
    Seems like this resets somehow the afp permissions in the firewall settings
    Everything fine on my network now.

  • Use SQL to INSERT a record into an Access table and populate using variables

    I am having difficulties with the following code:
    'Get my username
    UserNameWindows = GetUserName
    'Assemble my name and request corrections
    MsgBoxTitle = "What name do you want to use?"
    NewDefault = Replace(UserNameWindows, ".", " ")
    NewDefault = StrConv(NewDefault, vbProperCase)
    MyValue = InputBox(Message, MsgBoxTitle, NewDefault)
    RealName = MyValue
    'Assemble your email address
    MsgBoxTitle = "What is your email address?"
    NewDefault = UserNameWindows & "@calibreglobal.com.au"
    MyValue = InputBox(Message, MsgBoxTitle, NewDefault)
    EmailAddress = MyValue
    MsgBox "Your UserNameWindows value is " & UserNameWindows & "."
    'Insert UserNameWindows into the tblAuthorisedPeople table
    strSQL = "INSERT INTO tblAuthorisedPeople (Person, RealName, EmailAddress) VALUES (" & UserNameWindows & ",""" & RealName & """, """ & EmailAddress & """)"
    DoCmd.RunSQL (strSQL)
    It asks me to enter the value for the Person field into a dialogue box instead of using the value of UserNameWindows.
    After entry, it accepts the other values and enters the record correctly.
    I have also tried this SQL string without success
    strSQL = "INSERT INTO tblAuthorisedPeople (Person, RealName, EmailAddress) VALUES (" & Forms!frmCreateNew!UserNameWindows & ",""" & RealName & """, """ & EmailAddress & """)"
    Any comments?
    Barry Cuthbertson

    Found the error. I had used the rules for the syntax from a web forum reply which appears to have been incorrect!
    strSQL = "INSERT INTO tblAuthorisedPeople (Person, RealName, EmailAddress) VALUES (""" & UserNameWindows & """,""" & RealName & """, """ & EmailAddress &
    This seems to be working well as the moment
    All finished.
    Barry GC
     

Maybe you are looking for