PDA

View Full Version : Input with a form differently


ABC123

totalbiz
08-29-2014, 08:16 PM
Hi Everyone,

I need to display a form that I populated with fields from a table, but I don't want it to retrieve an existing record or add a new record at that moment. I need to fill out the form, then create a new record and save it with the data I input. This save would happen when I click a button on the form. I can use either action scripting or xbasic, I am familiar with both. Thank you in advance for any help.

GGandhi
08-29-2014, 08:45 PM
take a look at opening the form as dialog method.
since I don't work with desktops this may or may not be the answer.

MoGrace
08-29-2014, 09:30 PM
You could add one blank record to your table and fetch that for editing. Or you could fill the form with variables that mimic your fields, create your record from them, then show the actual form with fields on it - using a conditional object perhaps to hide the variables and show the fields?

Stan Mathews
08-29-2014, 11:55 PM
I need to fill out the form, then create a new record and save it with the data I input.

You've apparently figured out a better way to do things than the normal way data entry is done. Care to share what led you to this insight?

Tom Cone Jr
08-30-2014, 09:43 AM
Don,

If you're trying to begin a new record for the user, but not save it for them...

1) open the form, but use the option to keep it hidden
2) begin a new record in the called form
3) assign field values to the objects in the called form
4) show the form
5) activate the form, placing the cursor (focus) on the most convenient object for the user (might be the save button).

There are several ways to populate fields in the called form. This thread illustrates them using xbasic. (http://msgboard.alphasoftware.com/alphaforum/showthread.php?22928-Pass-Values-between-forms-Full&highlight=pass+values)

-- tom

DaveM
08-30-2014, 12:10 PM
Actually, you are thinking the way we did it 20+ years ago. We created variables for all the fields on a form and when populated we wrote it to the table(s). I have a couple of apps with certain forms still done that way in alpha. It takes longer to build, but very efficient.

20+ years ago, it was considered idiocy to write directly to a table field.

MoGrace
08-30-2014, 01:37 PM
It's hard to guess at the best answer when neither the scenario nor the reason is given.

Stan Mathews
08-30-2014, 06:56 PM
Scatter() and gather(), been there, did that, didn't spring for the t-shirt.

http://msgboard.alphasoftware.com/alphaforum/showthread.php?46026-Memory-Variables&highlight=scatter

totalbiz
09-04-2014, 02:11 PM
Thanks Robin,

There are interesting possibilities for a solution.

totalbiz
09-04-2014, 02:18 PM
Hi Stan,

I am trying to figure out if your response is meant to be a "shot" or not. If not my apologies and I really am just trying to find an answer to a problem I am having with a customer's system. If it is then, wow, calm down, I just asked a question.

Stan Mathews
09-04-2014, 02:21 PM
Don't know what a shot is, so no, it wasn't.

I was originally asking why the need to do something completely outside the normal way data entry is done in Alpha.

totalbiz
09-04-2014, 02:26 PM
Hi Robin,

What is happening is that I have a customer that I wrote a shipping application for and it generates with an auto-increment a sequence number. The customer wants to see this sequence number without any breaks in sequence without an explanation. The problem is the users go into the application all day long and they might make a mistake and want to cancel what they are doing. This happens a lot so there are a lot of records which are "blanks", or records with a sequence number but aren't a valid shipping record. I thought if I could add the record after the form shows and entry is done that it would avoid this problem.

Tom Cone Jr
09-04-2014, 03:06 PM
Don,

Is the data entry form based on a single table or a set of tables?

-- tom

Al Buchholz
09-04-2014, 03:28 PM
Don

Sounds like auto-increment is not the tool to use for your sequence number.

When the parent record is saved, write the sequence number by determining the next value at that time.

There are a number of ways to 'get' the next value.

I'm not sure what would be the best way for you.

Search the code archive and learningalpha.com for some examples.

Charles Hoens
09-04-2014, 04:50 PM
Don,

If I understand you, this is what I am currently doing for a client.

I created a config.dbf in which I store the current invoice number. I also use a temp database with all the same fields as the current dbf. The user then "writes" to that temp.dbf and I allow him to see the current invoice number from the config.dbf. If he decides to save the input, the invoice number is then written to the temp.dbf and then everything is written to a new entry in the main.dbf. The config.dbf is then incremented by 1, BUT only if he writes/saves the file. In this way, several people can be going in and out at any time, however the only time the invoice number is stored is when it is written.

Not sure if this is where you are going, but I hope it might help.

MoGrace
09-04-2014, 06:31 PM
Hi Robin,

What is happening is that I have a customer that I wrote a shipping application for and it generates with an auto-increment a sequence number. The customer wants to see this sequence number without any breaks in sequence without an explanation. The problem is the users go into the application all day long and they might make a mistake and want to cancel what they are doing. This happens a lot so there are a lot of records which are "blanks", or records with a sequence number but aren't a valid shipping record. I thought if I could add the record after the form shows and entry is done that it would avoid this problem.Hi Don,
It sounds as though the form they are viewing allows continuous enters which creates the incomplete record. If the form opens in recno order to the last record that might help if all they want to know is the last number used. You might also prevent the saving of a form unless key fields have been completed and require the use of your button(s) to save, cancel or delete it.

How and why users do what they do is a mystery even when you stand there and watch them!

GGandhi
09-04-2014, 08:13 PM
why not have a table called controlData and keep next invoiceId, next checkId, next smethingId and when ready to save the record the xbasic will go get that number and update that number +1 and create a new record with the retrieved number? so if the record is cancelled no new record is added. I would imagine that this will require an xdialog from than table tied regular form.

edit: I see this is suggested in post #15

totalbiz
09-05-2014, 11:56 AM
Don,

Is the data entry form based on a single table or a set of tables?

-- tom

Hi Tom,

It is a set but I will only allow entry of the fields in the child table when the parent record has been added.

totalbiz
09-05-2014, 11:58 AM
Don,

If I understand you, this is what I am currently doing for a client.

I created a config.dbf in which ...

Not sure if this is where you are going, but I hope it might help.

Hi Charles,

Thank you for the reply. This seems to be the approach I need to take.

Tom Cone Jr
09-05-2014, 02:36 PM
Don,

It sure sounds like you need to change your data entry sequence. I'd investigate the use of a new tables and a new set. The new tables would have the same structure as your current tables, as would the new set. Do your data entry using forms based on the new set. Data entry would essentially be on a scratchpad. Provide a button they would use to commit the new records to disk, and then create new records in your "real" tables, assigning field values from the scratchpad records.

Use the scratchpad only for entering new transactions.