PDA

View Full Version : Applying a script to a button - Help!


ABC123

Gary Marlon
08-19-2000, 12:36 PM
I want a button in a form, when pressed, to print the form just filled out. I've tried applying the following script:
enter_end(db_current(1), .T.)
card_spawn("print_preview", "USE=~RECEIPT~ TYPE=~REP0~ SPAWNDB=c:a5pos.dbf ")
card_return ()

to save the entered info then run a report, whose filter expression is: RECCOUNT()=RECNO(), to print the last record entered. But I get an error message: ENTER_BEGIN before ENTER_END. How can I eliminate the error message, or more important, how can I send the info just entered to the printer? I'm obviously a novice in Xbasic, HELP!

Jim Rowlen
08-19-2000, 11:25 PM
If I'm ready (and guessing) right your error message is indicating that it can't do an enter_end unless the for is in and "enter"begin" state. Someone is probably clicking the button while in view mode.

One way to get around this in some situations would be to test the entry status and send an error message

IF db_mode_get(db_current()) > 0 THEN
Choice = ui_msg_box("HOLD IT A SECOND","SAVE ORDER FIRST, THEN YOU MAY DO THIS",64)
else
' you're stuff
but it's not as good as the next method fot your situation.

Another would be to use a structure like

IF db_mode_get(db_current()) = 1 THEN ' change mode
'put change_end stuff here
elseIF db_mode_get(db_current()) = 2 THEN ' enter mode
'put enter_end stuff here
end if