Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

auto-enter calculation for date and number

Featured Replies

  • Newbies

I am very new to FMPRO7. I have html and Flash programming experience, so I understand the basics of programming.

Can someone help me get started on creating a solution to the following problems?

- User types in 6 digit number (xxxxxx) tabs out to have 6 digits formatted to xx-xx-xx

- User types in 8 digit number (xxxxxxxx) tabs out to have 8 digits formatted to xx/xx/xxxx

Any advise or help in this matter would be greatly appreciate. smile.gif

Thanks for your time,

Carl

I assume the input is a text field. Make it auto-enter by calculation and allow the existing value to be replaced. Use the following calculation:

Case ( Length ( TextField ) = 6 ; Left ( TextField; 2 ) & "-" & Middle ( TextField ; 3 ; 2 ) & "-" & Right ( TextField ; 2 ); Length ( TextField ) = 8 ; Left ( TextField; 2 ) & "/" & Middle ( TextField ; 3 ; 2 ) & "/" & Right ( TextField ; 4 ) ; "Error" )

This will show Error if the number of characters are not 6 or 8. If you omit " ; "Error"", the field will return nothing in this case. If you replace "Error" with TextField then what you entered will be returned if the number is 6 or 8 characters.

  • Author
  • Newbies

Thanks for the speedy reply. I like what you have done here. I need one for a Medical record field and one for date field. Can you seperate the code into two? Do I need to define fields as date if I'm going to print reports by date range? Thanks for your time,

Carl

Let( N = Filter( TextField1; "0123456789" );

Case( Length(N) = 6; Left( N; 2 ) & "-" & Middle( N; 3; 2 ) & "-" & Right( N; 2 ); "Error" )

)

The second one will not work on a date field. It will have to be a text field. But you can use a calculated date field of GetAsDate(TextField1) for your searches and reports.

Let( D = Filter( TextField2; "0123456789" );

Case( Length(D) = 8; Left( D; 2 ) & "/" & Middle( D; 3; 2 ) & "/" & Right( D; 4 ); "Error" )

)

  • Author
  • Newbies

WOW! That worked perfectly! Thanks again. How do I print a report; field "Destruction Date"(text) by date range? (For example 05/01/2005 - 05/31/2005)

Thank you for your time,

Carl

Use the GetAsDate calculation field and either manually enter 5/1...5/31 in Find Mode or have a script

Set Error Capture [On]

Enter Find Mode [ ]

Set Field [datefield; globaldatestart & "..." & globaldateend]

Perform Find [ ]

If [Get(FoundCount)]

{do something if records found}

Else

{do something if no records found}

End If

where globaldatestart and globaldateend are two date fields stored as globals whose criteria is entered in Browse Mode.

  • Author
  • Newbies

This is good stuff. Again I am a noob and appreciate the help. I like to contribute to forums when ever I can, because I get so much from them. Unfortunately this is not my area of expertise, yet. smile.gif

I like the fact that we can automate tasks in FMPRO7. Can you help me apply the script? I don't know where to begin.

  • 2 weeks later...
  • Author
  • Newbies

Thank you for all the great information. I need to add a check digit to my xx-xx-xx entery to read xx-xx-xx-x. Can you help me with the code for this?

I am using the following code:

Let( N = Filter( M.R.#; "0123456789" );

Case( Length(N) = 7; Left( N; 2 ) & "-" & Middle( N; 3; 2 ) & "-" & Middle( N; 5; 2 ) & "-" & Right( N; 1 ); "Error" )

)

Is there a more efficent way?

Need to auto format a seven digit entry of ####### to ##-##-##-#.

Any input would be appreciated.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.