Comparing text and number fields

I have AutoNumber field EnvelopeNumber and text field AuthenticationCode, 
with the default for AuthenticationCode equalling EnvelopeNumber. In Allen 
Browne's code to duplicate records, I have code to update the 
AuthenticationCode if it equals the AutoNumber, but accept it if the user has 
entered his own code.

        If Me.AuthenticationCode = Me.EnvelopeNumber Then
        !AuthenticationCode = !EnvelopeNumber
        Else
        !AuthenticationCode = Me.AuthenticationCode
        End If

This always copies the AuthenticationCode, I assume because Access does not 
recognise that a number field can equal a text field.

Thanks for any help.
Dudley
0
Utf
11/19/2009 10:01:02 PM
access.formscoding 7493 articles. 0 followers. Follow

4 Replies
1091 Views

Similar Articles

[PageSpeed] 33

Try

If CLng(Me.AuthenticationCode) = Me.EnvelopeNumber Then


-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Dudley" <Dudley@discussions.microsoft.com> wrote in message 
news:81EC157E-015D-46BB-A825-21AB530FB272@microsoft.com...
>I have AutoNumber field EnvelopeNumber and text field AuthenticationCode,
> with the default for AuthenticationCode equalling EnvelopeNumber. In Allen
> Browne's code to duplicate records, I have code to update the
> AuthenticationCode if it equals the AutoNumber, but accept it if the user 
> has
> entered his own code.
>
>        If Me.AuthenticationCode = Me.EnvelopeNumber Then
>        !AuthenticationCode = !EnvelopeNumber
>        Else
>        !AuthenticationCode = Me.AuthenticationCode
>        End If
>
> This always copies the AuthenticationCode, I assume because Access does 
> not
> recognise that a number field can equal a text field.
>
> Thanks for any help.
> Dudley 


0
Douglas
11/19/2009 10:25:22 PM
Thanks very much. This works fine so long as the AuthenticationCode is all 
numbers, but it can include letters and then it gives a type mismatch. Is 
there a way round this?

Thanks
Dudley

"Douglas J. Steele" wrote:

> Try
> 
> If CLng(Me.AuthenticationCode) = Me.EnvelopeNumber Then
> 
> 
> -- 
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
> 
> 
> "Dudley" <Dudley@discussions.microsoft.com> wrote in message 
> news:81EC157E-015D-46BB-A825-21AB530FB272@microsoft.com...
> >I have AutoNumber field EnvelopeNumber and text field AuthenticationCode,
> > with the default for AuthenticationCode equalling EnvelopeNumber. In Allen
> > Browne's code to duplicate records, I have code to update the
> > AuthenticationCode if it equals the AutoNumber, but accept it if the user 
> > has
> > entered his own code.
> >
> >        If Me.AuthenticationCode = Me.EnvelopeNumber Then
> >        !AuthenticationCode = !EnvelopeNumber
> >        Else
> >        !AuthenticationCode = Me.AuthenticationCode
> >        End If
> >
> > This always copies the AuthenticationCode, I assume because Access does 
> > not
> > recognise that a number field can equal a text field.
> >
> > Thanks for any help.
> > Dudley 
> 
> 
> .
> 
0
Utf
11/19/2009 11:21:03 PM
You could  convert them both to a string before you compare them.

If CStr(Me.AuthenticationCode) = CStr(Me.EnvelopeNumber) Then


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia

"Dudley" <Dudley@discussions.microsoft.com> wrote in message 
news:BDE0DB67-E66E-4733-8F13-DD19CE9BA7BF@microsoft.com...
> Thanks very much. This works fine so long as the AuthenticationCode is all
> numbers, but it can include letters and then it gives a type mismatch. Is
> there a way round this?
>
> Thanks
> Dudley
>
> "Douglas J. Steele" wrote:
>
>> Try
>>
>> If CLng(Me.AuthenticationCode) = Me.EnvelopeNumber Then
>>
>>
>> -- 
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Dudley" <Dudley@discussions.microsoft.com> wrote in message
>> news:81EC157E-015D-46BB-A825-21AB530FB272@microsoft.com...
>> >I have AutoNumber field EnvelopeNumber and text field 
>> >AuthenticationCode,
>> > with the default for AuthenticationCode equalling EnvelopeNumber. In 
>> > Allen
>> > Browne's code to duplicate records, I have code to update the
>> > AuthenticationCode if it equals the AutoNumber, but accept it if the 
>> > user
>> > has
>> > entered his own code.
>> >
>> >        If Me.AuthenticationCode = Me.EnvelopeNumber Then
>> >        !AuthenticationCode = !EnvelopeNumber
>> >        Else
>> >        !AuthenticationCode = Me.AuthenticationCode
>> >        End If
>> >
>> > This always copies the AuthenticationCode, I assume because Access does
>> > not
>> > recognise that a number field can equal a text field.
>> >
>> > Thanks for any help.
>> > Dudley
>>
>>
>> .
>> 


0
Jeanette
11/20/2009 3:13:05 AM
That works fine. Thanks very much for your help.
Dudley

"Jeanette Cunningham" wrote:

> You could  convert them both to a string before you compare them.
> 
> If CStr(Me.AuthenticationCode) = CStr(Me.EnvelopeNumber) Then
> 
> 
> Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
> 
> "Dudley" <Dudley@discussions.microsoft.com> wrote in message 
> news:BDE0DB67-E66E-4733-8F13-DD19CE9BA7BF@microsoft.com...
> > Thanks very much. This works fine so long as the AuthenticationCode is all
> > numbers, but it can include letters and then it gives a type mismatch. Is
> > there a way round this?
> >
> > Thanks
> > Dudley
> >
> > "Douglas J. Steele" wrote:
> >
> >> Try
> >>
> >> If CLng(Me.AuthenticationCode) = Me.EnvelopeNumber Then
> >>
> >>
> >> -- 
> >> Doug Steele, Microsoft Access MVP
> >> http://I.Am/DougSteele
> >> (no private e-mails, please)
> >>
> >>
> >> "Dudley" <Dudley@discussions.microsoft.com> wrote in message
> >> news:81EC157E-015D-46BB-A825-21AB530FB272@microsoft.com...
> >> >I have AutoNumber field EnvelopeNumber and text field 
> >> >AuthenticationCode,
> >> > with the default for AuthenticationCode equalling EnvelopeNumber. In 
> >> > Allen
> >> > Browne's code to duplicate records, I have code to update the
> >> > AuthenticationCode if it equals the AutoNumber, but accept it if the 
> >> > user
> >> > has
> >> > entered his own code.
> >> >
> >> >        If Me.AuthenticationCode = Me.EnvelopeNumber Then
> >> >        !AuthenticationCode = !EnvelopeNumber
> >> >        Else
> >> >        !AuthenticationCode = Me.AuthenticationCode
> >> >        End If
> >> >
> >> > This always copies the AuthenticationCode, I assume because Access does
> >> > not
> >> > recognise that a number field can equal a text field.
> >> >
> >> > Thanks for any help.
> >> > Dudley
> >>
> >>
> >> .
> >> 
> 
> 
> .
> 
0
Utf
11/20/2009 1:30:05 PM
Reply:

Similar Artilces:

Summing instances of text across worksheets
Hello, I have a workbook with separate sheets for each month. The sheets contain a list client names (entered exactly the same on each sheet). I need to summarize how many times a client name appears in total. For example, John Brown may appear Jan & Feb (=2) where Mary Brown may appear Jul, Sep, Dec (=3). I've been trying pivot tables without luck. Hoping someone can help. Thanks in advance! Never mind, I consolidated all the worksheet data into one and the pivot table works fine. Thanks anwyay! "George" wrote: > Hello, I have a workbook with separate sheets fo...

Find feature does not work with HTML messages (Content-type: text/html)
I have Outlook 2000 SP-3 running under Windows ME. When using the Find feature to locate all e-mails with a given word in the message, no items are found if the e-mails are of "text/html" content-type. The Find feature appears to work for any messages that have URLs embedded and are "multipart/alternative" or "text/plain" content-type. I noticed a similar post several months ago (see http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=%23qSBYIssDHA.2224%40TK2MSFTNGP09.phx.gbl). Is there a work-around for this problem, or should this be reported t...

Technique used to rotate text labels when creating a PDF file from Access
This might be of help to some people. I have been producing some PDF reports lately directly from Access using the basic techniques found here: http://groups.google.com/group/comp.databases.ms-access/msg/a49f0ddea9315902 The rotation technique I use below can only be used when Access creates the PDF file directly or when Access uses some PDF creation tool that allows the developer to insert additional PDF commands. I don't think that the Access 2007 PDF Add-in from Microsoft allows such customization. Even if you can find an appropriate place to put the PDF commands within...

Access 2000
Hello all, I have a field named Field213 that holds (CASETYPE) from the database. When I open the form, I want it to look at that field and make field163 visible depending on what it stored in Field213. Right now it only becomes visible if I manually change what is in field213, then field163 becomes visible. I should mention that I have field163 as visible no and display always, the same as field PBISUB, Field382 and Field163. Probably something simple, but I can't seem to see it right now. I have the following: Private Sub Field213_BeforeUpdate(iC As Integer) If Me!CASETYPE = &qu...

Setting random number range based on query, not table
I have a "quiz" form that randomly pulls up questions from my table. It works fine, and I don't mind that it repeats questions. This allows me to sit and review for as long as I want. The problem is, that I want to use criteria in a query to limit the available questions. If I base this form on a query and limit the number of questions, the code I am using is still setting the maximum number as the number of records in my table. In the past, I had a similar database (which I have lost) that would open the form, set the selector to the last record available to the form,...

Serial number error in sales order entry window (2nd post)
I'm reposting this because there was no response to my first post. I'm sure I'm not the only one that has had this problem. I noticed that one of my coworkers invoiced and added (overided) a serial number into the Great Plains instead of allocating one of the existing ones. How do I return this serial number w/out affecting my inventory? I need to: 1. Return the item w/the wrong serial number. 2. Reinvoice the correct serial number. 3. NOT HAVE THE WRONG SERIAL NUMBER STUCK IN MY INVENTORY. How do I do this? Hi Paoakalani Try looking at Serial Number edit, by Blue Moon...

How to compare "varchar" values?
I need to compare a student's score (that s/he got it after a test) with the score requirement. The problem is the scores are either a "character" only, i.e., "2" OR combined a "character" AND the '+'/ '-' character, i.e., 2+. For example, if the require score is 2+ and the student's score is 2 then that student is not qualified. The datatype of scores is varchar. Can you please help in programming how to compare these values? Thanks a lot in advance. I appreciate it. I see two approaches. The first one is a trick, ...

Compare and Highlight Rows
I have an excel file with two worksheets. is there a way to programatically compare the two worksheets to find matches and highlight those matches on each worksheet. They both have the same columns. I want to compare the InspectionID column. The Inspection ID column may have duplicates in both of the worksheets. I have never done anything in excel above the beginner level. However, I am a very skilled VBA programmer (programmed in ACCESS for over 10 years). Thank you You may find it easier to use Conditional formatting instead: For instance, with Sheet1 column A selected, and cel...

Edit the Auto Fill in the To: field
On the Send new message window, is there a way to edit the auto fill list for the To: Field. when i start to type in a name in the To Field the auto fill will provide a list of names to choose from. the one i most use is on the bottom of the list. How do i edit the list to get the one i use most to the top? Do you use the others as well? Editing the list will remove them from the list. If you again use the names, they will be added back to the same position. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the Swen virus, all e-...

display the value of an unbound textbox in a field within a table
I created 3 textboxs to calculate the number of business days between 2 dates. The 3rd textbox contains the value. I now want to have this value displayed in a table field. I'm sure this is easy but I'm a complete novice and have spent far too much time on this already. Can anyone help! Fibi, The general concept of tables is that they are for storage of data in the background. They are not for display of data. That is what forms and reports are for. Therefore, the appearance of the data in the tables is not normally relevant, and the display of calculated values is im...

Multi-field search form
Hi there, I am rather new to this place, so I would like to thank you all up front for any and all assistance you may provide. :) It has been a while since I worked with MS Access last. What I am trying to do is create a multi-field search form, where any of the fields can be filled which will display a result set. Preferably if no selection in the fields is made, the entire resultset should be shown - this is not a requirement, though. I seem to be a bit at a loss on how to procede with this task or to find any resources to help me get along. Again, thanks for any and ...

Manager Assist ...... Field Service Module
Hi to all, I wnat to ask about Manager Assist, that is used to manage the calls on the service call module...... is it a GP module or it is a separate software thank you in advance, ManageAssist is a seperate VB application that connects to the GP Field Service tables. It allows for both viewing of schedule calls as well as updating of certain records (i.e. Unavailable time, sick time, etc.) -- Gary Neumann Field Service Series Designer/Architect "Eng. Tareq Sabri" wrote: > Hi to all, > > I wnat to ask about Manager Assist, that is used to manage the calls on th...

Odd Looking Number
Hi I am using a spreadsheet in Excel 2002 on Windows XP, for some reason the account numbers (which someone input, along with addresses) have a little green mark in the corner of the cell. I thought it was to show that there is a comment, but it is not. When you click on the cell, a little warning sign shows, saying ERROR - number in this cell formatted as text or preceded by an apostrophe. When I click on the arrow by the warning sign, it says Number stored as text Convert to number Ignore error Edit in formula bar Error checking options Show formula in audinting toolbar Now I l...

Numbers turn red when equals to 0
Good day, Im monitoring our stock inventory using excel, i just want to know if I can make a certain cell turn red if my inventory is >5 or equal to zero.? Thanks -- shiela21cute ------------------------------------------------------------------------ shiela21cute's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=33169 View this thread: http://www.excelforum.com/showthread.php?threadid=529926 Check out Conditional formatting Ed -- EdMac ------------------------------------------------------------------------ EdMac's Profile: http://www.excelforum...

Text-To-Columns Fixed Width
When using Text-To-Columns, Excel "recognizes" that the data fits the Fixed Width criteria and PRE-assigns the width. In most of the cases I work with Excel is wrong 99% of the time. Is there a way to force Excel to NOT pre-assign the width (leave everything blank)? On the first panel of the wizard click Delimited, then on the second panel click space as the delimiter. Hope this helps. Pete On Feb 4, 12:50=A0am, TP <T...@discussions.microsoft.com> wrote: > When using Text-To-Columns, Excel "recognizes" that the data fits the Fix= ed > Width ...

how field name output same as input
Thanks for any help. I have a query from a couple tables, and one of the field names in the table is 'IGP' and I have a field in the query that was IGP and now I changed to IGP: iif(blah IGP blah) which gives me a circular error. The table is used by a bunch of other things, so I don't want to change the field name there, and the field name for the output is used by a bunch of things, so nor do I want to change the name there. I am using Access 2007. I thought about changing the output field to IGP_, and I could change the embedded queries in Excel that use it, but...

passing non-field value into vba
I need to pass the line item sequence number (lnitmseq) from the sales item detail entry window into vba. This isnt a visible field in the window, so i cannot "add field to vba" using the TOOLS --> customize toolbar window. Anyone have any idea how this can be done? Using the Modifier you can make the field visible, add it to VBA and then remove the modified window or make the field invisible again. While in the Window Layout mode, make sure that the Invisible fields are shown (Layout >> Show Invisible Fields) and then change the Visual Property, Visible = true and mov...

when I type a long number it shows up as smaller number and +
when converting from xls to csv format, some of my longer mortgage numbers get condensed into a smaller number with a letter, a plus sign and another number. example: 100020013120 turns into 1.0002E+11. Any way to get rid of this? Thanks, Yes, just specify the format that you want. Format Cells...>Number>0 decimal places Regards, Fred "SandyC" <SandyC@discussions.microsoft.com> wrote in message news:FA52E426-360E-4BE5-B63B-1209E673CA65@microsoft.com... > when converting from xls to csv format, some of my longer mortgage numbers > get conde...

Derived Field
I'd like to add a derived field to this situation: Parent Table : Shipments (pk)Shipment_No Shipment_Date Shipment_Size ....other fields... Child Table : Shipment_Inspection Shipment_No (connected field) Number_Out_Tolerance (bad ones in the shipment) ....other fields... I'd like to make a derived field "der_percent_good" that takes the shipment size that the inspection belongs to and does (1 - Number_Out_Tolerance/Shipment_Size)*100 to find the percent of the shipment that is Good. Thanks! ...

Date/Time field calculation
Hello, i am trying to make a sum calculation on a field that keeps duration of time. How can i do this? I get errors or zero as result. Thanks On Jun 21, 10:02 am, Stathis <s_paraske...@hotmail.com> wrote: > Hello, > i am trying to make a sum calculation on a field that keeps duration of > time. How can i do this? I get errors or zero as result. > Thanks You need to do the calculation at a level at least 1 level below what you want the answer to be in. Example msgbox DateDiff("h", #6/20/2007 1:00:00 AM#, #6/20/2007 1:30:00 PM#) will give an ans...

Rule not matching "from" field
I want to set up a rule that will match words in the "From" field. Sometimes I get mail like this: From: bill@somedomain.com [mailer@someotherdomain.com] I want to match "bill@somedomain.com". I can't figure out how to match it. I can't pick "from people or distribution list" because it won't let me match arbitrary email addresses. I can't pick "with specific words in the sender's address" it just doesn't work. So far as I can tell, it will only match the part in the brackets. Anon E. Mouse <fake@fake.com> wrote: &...

Need help extracting text from EDLs
I really am trying to learn this stuff, but I haven't programmed anything since my TRS-80 Basic days and I'm a bit overwhelmed. I want to extract text from Edit Decision Lists so that I have a list of shots used in a film. Here is an example of one event of an EDL: 002 TAPE004 V C 04:45:22:06 04:45:24:14 02:00:08:00 02:00:10:08 FROM CLIP NAME: 7C-4_B_ DLEDL: PATH: /raids/luc_1/bun/reel_02/oscans/1222/bun_7c_4_b_02/2048x1556/ The text that follows "FROM CLIP NAME:" is the name of the clip that I want to extract so that I have a document on onl...

Text box and formatting?
I am working on class schedule and have one text box which spans a few pages. Pages are double columns. I have a header for each class and paragraph given for class description. On the last page, last column, one description appears at the top with empty space for the rest of the column. I would like to change the formatting of the text in the whole text-box so that most of the last column is used. I can select the text in the text box which expands over the few pages and play with the font size, but that would mean that all the text would be the same size. Is there a way that text...

Code to send SMS text message?
Hi, I would like to send an SMS text message to a cel phone via code within Excel 2007. Has anyone done this? What code / services / products do I need to accomplish this? Does anyone have an example? Thanks in advance. --Dan What gateway are you using? What you would need to do is to snd a internet message to a gateway provider which would then send the messae out on the wireless land. Most likely you are using a webpage interface from your PC to interface with the gateway. So opening up an internet explorer and goiong to an URL is probably the method to use. ...

Rotating page numbers
I have a document with both page layouts (landscape and portrait) however the page numbers obviously will be pointing in the direction of the associated layout does anyone know how to be consistent in this? ...