# Auto populate fields

**URL:** <https://forum.xojo.com/t/auto-populate-fields/78085>\
**Category:** Getting Started\
**Created:** [November 11, 2023, 8:08pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085 "2023-11-11T20:08:33Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Noah\_Rosenfeld](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@Noah\_Rosenfeld](https://forum.xojo.com/u/Noah_Rosenfeld)\
**Post date:** [November 11, 2023, 8:08pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/1 "2023-11-11T20:08:33Z")

</div>

I have 2 text fields and I want one to detect when there is a number in the field and then have that number auto populate into the second text field.

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [November 11, 2023, 8:19pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/2 "2023-11-11T20:19:20Z")

</div>

in the textchanged event…

```auto

try
if isnumeric( me.text) then otherfield.text = me.text
catch
end try

```

---

<div class="post-metadata">

**Author:** ![Brandon\_Warlick](https://forum.xojo.com/user_avatar/forum.xojo.com/brandon_warlick/32/238_2.png) [@Brandon\_Warlick](https://forum.xojo.com/u/Brandon_Warlick)\
**Post date:** [November 11, 2023, 8:20pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/3 "2023-11-11T20:20:04Z")

</div>

Noah, one way to do this is with the TextChanged event. Drag a TextField on to the window. Name it TextField1. Drag another TextField on to the Window. Name it TextField2. Right click on TextField1 and select Add To “TextField1” Event Handler. Then select the event TextChanged. In that event, put the code:

```auto
TextField2.Text = me.Text

```

I left out the part about determining the number, but @Jeff_Tullin showed you.

---

<div class="post-metadata">

**Author:** ![Noah\_Rosenfeld](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@Noah\_Rosenfeld](https://forum.xojo.com/u/Noah_Rosenfeld)\
**Post date:** [November 11, 2023, 8:22pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/4 "2023-11-11T20:22:00Z")

</div>

Alright I understand that part!

---

<div class="post-metadata">

**Author:** ![Noah\_Rosenfeld](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@Noah\_Rosenfeld](https://forum.xojo.com/u/Noah_Rosenfeld)\
**Post date:** [November 11, 2023, 8:22pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/5 "2023-11-11T20:22:32Z")

</div>

I don’t get that part

---

<div class="post-metadata">

**Author:** ![Noah\_Rosenfeld](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@Noah\_Rosenfeld](https://forum.xojo.com/u/Noah_Rosenfeld)\
**Post date:** [November 11, 2023, 8:30pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/6 "2023-11-11T20:30:17Z")

</div>

i got

 ![image](https://forum.xojo.com/uploads/default/original/2X/c/c26f7bbe18a14589db949e2de1b138286fbaa14f.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [November 11, 2023, 8:35pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/7 "2023-11-11T20:35:43Z")

</div>

> [@Jeff\_Tullin](#):
>
> `if isnumeric( me.text) then oldfield.text = me.text`

Is there a reason why you did not use this?

---

<div class="post-metadata">

**Author:** ![Noah\_Rosenfeld](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@Noah\_Rosenfeld](https://forum.xojo.com/u/Noah_Rosenfeld)\
**Post date:** [November 11, 2023, 8:38pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/8 "2023-11-11T20:38:37Z")

</div>

happenedFeil and oldFeild are the to fields im using here

---

<div class="post-metadata">

**Author:** ![Noah\_Rosenfeld](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@Noah\_Rosenfeld](https://forum.xojo.com/u/Noah_Rosenfeld)\
**Post date:** [November 11, 2023, 8:39pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/9 "2023-11-11T20:39:35Z")

</div>

![image](https://forum.xojo.com/uploads/default/original/2X/0/0088ed658fb2bd0c21407d348640cf8854cf6748.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [November 11, 2023, 8:42pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/10 "2023-11-11T20:42:47Z")

</div>

> [@Noah\_Rosenfeld](#):
>
> happenedFeil and oldFeild are the to fields im using here

Yes, BUT you didn’t include **.text** , and you dint use isnumeric  
**me.text** in the textchanged event of happenedFeil would be the same as  
happenedFeil.t **ext**

---

<div class="post-metadata">

**Author:** ![Noah\_Rosenfeld](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@Noah\_Rosenfeld](https://forum.xojo.com/u/Noah_Rosenfeld)\
**Post date:** [November 11, 2023, 8:44pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/11 "2023-11-11T20:44:06Z")

</div>

I got it working but I also want to be able to put other letters in the field and only the number in the second field

---

<div class="post-metadata">

**Author:** ![Noah\_Rosenfeld](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@Noah\_Rosenfeld](https://forum.xojo.com/u/Noah_Rosenfeld)\
**Post date:** [November 11, 2023, 8:45pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/12 "2023-11-11T20:45:40Z")

</div>

Yeah, sorry i fixed that but

> [@Auto populate fields](https://forum.xojo.com/t/auto-populate-fields/78085/11):
>
> I got it working but I also want to be able to put other letters in the field and only the number in the second field

---

<div class="post-metadata">

**Author:** ![Noah\_Rosenfeld](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@Noah\_Rosenfeld](https://forum.xojo.com/u/Noah_Rosenfeld)\
**Post date:** [November 11, 2023, 8:48pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/13 "2023-11-11T20:48:24Z")

</div>

![Capture](https://forum.xojo.com/uploads/default/original/2X/3/3dae23951fb5eb9abb7942852f4a01d4bf01971a.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [November 11, 2023, 8:50pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/14 "2023-11-11T20:50:46Z")

</div>

> [@Auto populate fields](#):
>
> I also want to be able to put other letters in the field and only the number in the second field

New information.  
Now you mean ‘if there are any numbers’  
Some people would advise using Regex. It wont help you.

Consider these:

A123 - you want 123?

A12B34 - do you want 1234?

1234E5 - this is a big number if treated as scientific notation … 123400000

You _could_ extract all numbers using a loop: something like this…

```auto

var nums as string
for x as integer = 1 to me.text.length
   //if the nth character is a number, add it to the string nums
next

if nums > "" then oldfield.text = nums

```

---

<div class="post-metadata">

**Author:** ![Noah\_Rosenfeld](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@Noah\_Rosenfeld](https://forum.xojo.com/u/Noah_Rosenfeld)\
**Post date:** [November 11, 2023, 8:54pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/15 "2023-11-11T20:54:26Z")

</div>

![Capture](https://forum.xojo.com/uploads/default/original/2X/0/072ee167a502e81d3f4347b6d6d4da143fe67036.png)

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [November 11, 2023, 8:55pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/16 "2023-11-11T20:55:22Z")

</div>

Why would you assume that a number in the ‘tell me’ box is an age?

**‘Tell me exactly what happened?’**"Well, I bought **6** eggs to make an omelette…’

I suspect

**Are you with the patient now?** can be a checkbox… it’s faster than a dropdown.

and ‘concsious’ should be ‘conscious’  
🙂

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [November 11, 2023, 8:56pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/17 "2023-11-11T20:56:17Z")

</div>

**Oldfield** … you spelled that as **Oldfeild**

---

<div class="post-metadata">

**Author:** ![Noah\_Rosenfeld](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/0ea827/32.png) [@Noah\_Rosenfeld](https://forum.xojo.com/u/Noah_Rosenfeld)\
**Post date:** [November 11, 2023, 8:59pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/18 "2023-11-11T20:59:26Z")

</div>

> [@Jeff Tullin](https://forum.xojo.com/t/jeff-tullin/78086):
>
> I ran out of replies could you send email or other form of communication. @Jeff_Tullin

I ran out of replies

noahr48@educbe.ca

email me

---

<div class="post-metadata">

**Author:** ![Jeff\_Tullin](https://forum.xojo.com/user_avatar/forum.xojo.com/jeff_tullin/32/693_2.png) [@Jeff\_Tullin](https://forum.xojo.com/u/Jeff_Tullin)\
**Post date:** [November 11, 2023, 9:05pm UTC](https://forum.xojo.com/t/auto-populate-fields/78085/19 "2023-11-11T21:05:40Z")

</div>

The last code I gave you is not complete. I left some of it for you to write.
