Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Xdialog will not close before report prints

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Xdialog will not close before report prints

    Need to get xdialog to close before report prints.
    any help would be appreciated.
    Thanks
    Charlie Crimmel

    Code:
    'Date Created: 20-Jan-2011 01:26:47 PM
    'Last Updated: 20-Jan-2011 02:00:15 PM
    'Created By  : E009933
    'Updated By  : E009933
    
    'Run script: xdiag_start_end_empnum
    'script_play("xdiag_start_end_empnum")
    'Create an XDialog dialog box to prompt for parameters.
    trace.clear()
    DIM GLOBAL vstartdate as D
    DIM GLOBAL venddate as D
    DIM GLOBAL varC_result as C
    DIM GLOBAL vempnum as C
    Dim Global Printflag As L
    
    var->vstartdate={}
    var->venddate = {}
    var->vempnum=""
    var->Printflag = .F.
    
    dlg_title = "Enter Selection for Report"
    heading_string = "Enter Date Range"
    heading_string2 = "Enter Employee Number- Dont forget  the Dashes"
    heading_string3 = "Example 05-1100-0"
    
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    Delete XdialogStyle
    dim XDialogStyle as p
    XDialogStyle.AccentColor = "White"
    XDialogStyle.Color = "#153+204+255"
    varC_result = ui_modeless_dlg_box(dlg_title,<<%dlg%
    {Windowstyle=Gradient Horizontal Bottom}
    {region}
    {text=55,1:heading_string};
    {endregion};
    {region}
    Enter Start date:| [%DATE;P=popup.calendar(dtoc(vstartdate));I=popup.calendar%.30vstartdate!vstartdate_*];
    Enter Ending date:| [%DATE;P=popup.calendar(dtoc(venddate));I=popup.calendar%.30venddate!venddate_*];
    {endregion};
    {line=1,0};
    {region3}
    {text=35,1:heading_string2};
    {text=35,1:heading_string3};
    Enter Employee Number: [.20vempnum!vempnum];
    {endregion3};
    {line=1,0};
    
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%,<<%code%
    if left(a_dlg_button,11) = "vstartdate_" then 
    	if a_dlg_button = "vstartdate_killfocus" then 
    		var->vstartdate = ctod(dtoc(vstartdate))
    	end if 
    	var->printflag = .F.
    	a_dlg_button = ""
    end if 
    
    if left(a_dlg_button,9) = "venddate_" then 
    	if a_dlg_button = "venddate_killfocus" then 
    		var->venddate = ctod(dtoc(venddate))
    	end if 
    	var->printflag = .F.
    	a_dlg_button = ""
    end if
    
    if left(a_dlg_button,7) = "vempnum" then 
    	if a_dlg_button = "vempnum_killfocus" then 
    		var->vempnum = vempnum
    	end if 
    	var->printflag = .F.
    	a_dlg_button = ""
    end if
    
    if a_dlg_button = "OK" then 
    '	a_dlg_button = ""
    	If var->vstartdate <> {} .and. var->venddate <> {} .and. var->vempnum <> "" then
    		var->printflag = .T.
    		trace.WriteLn("Printflag ="+ printflag)
    		trace.WriteLn("Beginning Date ="+ vstartdate)
    		trace.WriteLn("Ending Date ="+ venddate)
    		trace.WriteLn("Employee Number ="+ vempnum)
    		ui_modeless_dlg_close(dlg_title)
    		goto printreport
    	else
    		code = UI_OK + UI_QUESTION_SYMBOL 
    		ui_msg_box("Question", "Fields cannot be Blank? ", code)
    		ui_modeless_dlg_close(dlg_title)
    	end if
    end if
    
    if a_dlg_button = "CANCEL" then 
    	a_dlg_button = ""
    	trace.WriteLn("Beginning Date ="+ vstartdate)
    	trace.WriteLn("Ending Date ="+ venddate)
    	trace.WriteLn("Employee Number ="+ vempnum)
    	var->printflag = .F.
    	ui_modeless_dlg_close(dlg_title)
    end if
    printreport:
    if var->printflag = .T. then 
    	'Preview a report, label, letter, form or browse layout. You can specify which records to preview.
    	query.filter = "(Entrydate >= Var->vstartdate  )  .and. (Entrydate <= Var->venddate  ) .and. (Empnum = Var->vempnum  )"
    	query.order = "recno()"
    	'replace variables in the filter with their actual values	
    	query.filter = convert_expression(query.filter,"V")
    
    	'Prompt user whether to print, or preview the layout. Set default to Preview 
    	prompt_result = ui_get_print_or_preview("Preview ")
    	If prompt_result = "Print" then
    		:Report.Print("Employee Hours4",query.filter,query.order)
    	Else if prompt_result = "Preview" then 
    		:Report.Preview("Employee Hours4",query.filter,query.order)
    	End if
    end if
    
    %code%)

    #2
    Re: Xdialog will not close before report prints

    Try removing the

    goto printreport

    and moving this

    Code:
    if var->printflag = .T. then 
    	'Preview a report, label, letter, form or browse layout. You can specify which records to preview.
    	query.filter = "(Entrydate >= Var->vstartdate  )  .and. (Entrydate <= Var->venddate  ) .and. (Empnum = Var->vempnum  )"
    	query.order = "recno()"
    	'replace variables in the filter with their actual values	
    	query.filter = convert_expression(query.filter,"V")
    
    	'Prompt user whether to print, or preview the layout. Set default to Preview 
    	prompt_result = ui_get_print_or_preview("Preview ")
    	If prompt_result = "Print" then
    		:Report.Print("Employee Hours4",query.filter,query.order)
    	Else if prompt_result = "Preview" then 
    		:Report.Preview("Employee Hours4",query.filter,query.order)
    	End if
    end if
    after the

    %code%)

    Remove the printreport: label

    Code:
    'Date Created: 20-Jan-2011 01:26:47 PM
    'Last Updated: 20-Jan-2011 02:00:15 PM
    'Created By  : E009933
    'Updated By  : E009933
    
    'Run script: xdiag_start_end_empnum
    'script_play("xdiag_start_end_empnum")
    'Create an XDialog dialog box to prompt for parameters.
    trace.clear()
    DIM GLOBAL vstartdate as D
    DIM GLOBAL venddate as D
    DIM GLOBAL varC_result as C
    DIM GLOBAL vempnum as C
    Dim Global Printflag As L
    
    var->vstartdate={}
    var->venddate = {}
    var->vempnum=""
    var->Printflag = .F.
    
    dlg_title = "Enter Selection for Report"
    heading_string = "Enter Date Range"
    heading_string2 = "Enter Employee Number- Dont forget  the Dashes"
    heading_string3 = "Example 05-1100-0"
    
    ok_button_label = "&OK"
    cancel_button_label = "&Cancel"
    Delete XdialogStyle
    dim XDialogStyle as p
    XDialogStyle.AccentColor = "White"
    XDialogStyle.Color = "#153+204+255"
    varC_result = ui_modeless_dlg_box(dlg_title,<<%dlg%
    {Windowstyle=Gradient Horizontal Bottom}
    {region}
    {text=55,1:heading_string};
    {endregion};
    {region}
    Enter Start date:| [%DATE;P=popup.calendar(dtoc(vstartdate));I=popup.calendar%.30vstartdate!vstartdate_*];
    Enter Ending date:| [%DATE;P=popup.calendar(dtoc(venddate));I=popup.calendar%.30venddate!venddate_*];
    {endregion};
    {line=1,0};
    {region3}
    {text=35,1:heading_string2};
    {text=35,1:heading_string3};
    Enter Employee Number: [.20vempnum!vempnum];
    {endregion3};
    {line=1,0};
    
    {region}
    <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
    {endregion};
    %dlg%,<<%code%
    if left(a_dlg_button,11) = "vstartdate_" then 
    	if a_dlg_button = "vstartdate_killfocus" then 
    		var->vstartdate = ctod(dtoc(vstartdate))
    	end if 
    	var->printflag = .F.
    	a_dlg_button = ""
    end if 
    
    if left(a_dlg_button,9) = "venddate_" then 
    	if a_dlg_button = "venddate_killfocus" then 
    		var->venddate = ctod(dtoc(venddate))
    	end if 
    	var->printflag = .F.
    	a_dlg_button = ""
    end if
    
    if left(a_dlg_button,7) = "vempnum" then 
    	if a_dlg_button = "vempnum_killfocus" then 
    		var->vempnum = vempnum
    	end if 
    	var->printflag = .F.
    	a_dlg_button = ""
    end if
    
    if a_dlg_button = "OK" then 
    '	a_dlg_button = ""
    	If var->vstartdate <> {} .and. var->venddate <> {} .and. var->vempnum <> "" then
    		var->printflag = .T.
    		trace.WriteLn("Printflag ="+ printflag)
    		trace.WriteLn("Beginning Date ="+ vstartdate)
    		trace.WriteLn("Ending Date ="+ venddate)
    		trace.WriteLn("Employee Number ="+ vempnum)
    		ui_modeless_dlg_close(dlg_title)
    	else
    		code = UI_OK + UI_QUESTION_SYMBOL 
    		ui_msg_box("Question", "Fields cannot be Blank? ", code)
    		ui_modeless_dlg_close(dlg_title)
    	end if
    end if
    
    if a_dlg_button = "CANCEL" then 
    	a_dlg_button = ""
    	trace.WriteLn("Beginning Date ="+ vstartdate)
    	trace.WriteLn("Ending Date ="+ venddate)
    	trace.WriteLn("Employee Number ="+ vempnum)
    	var->printflag = .F.
    	ui_modeless_dlg_close(dlg_title)
    end if
    %code%) 
    
    if var->printflag = .T. then 
    	'Preview a report, label, letter, form or browse layout. You can specify which records to preview.
    	query.filter = "(Entrydate >= Var->vstartdate  )  .and. (Entrydate <= Var->venddate  ) .and. (Empnum = Var->vempnum  )"
    	query.order = "recno()"
    	'replace variables in the filter with their actual values	
    	query.filter = convert_expression(query.filter,"V")
    
    	'Prompt user whether to print, or preview the layout. Set default to Preview 
    	prompt_result = ui_get_print_or_preview("Preview ")
    	If prompt_result = "Print" then
    		:Report.Print("Employee Hours4",query.filter,query.order)
    	Else if prompt_result = "Preview" then 
    		:Report.Preview("Employee Hours4",query.filter,query.order)
    	End if
    end if
    There can be only one.

    Comment


      #3
      Re: Xdialog will not close before report prints

      Did what Stan suggested and no luck.

      Even tried to make it a function, - did not work.

      there should be a way to close the xdialog and continue running a script.

      run a script
      pause the script
      run xdialog
      close xdialog
      resume the script

      any more ideas

      Comment


        #4
        Re: Xdialog will not close before report prints

        Charlie - this should work simply
        If the xdialog is getting parameters you are going to use in the report, after the xdialog finishes, you should be able to print using the vaiables - I do this all the time
        Cole Custom Programming - Terrell, Texas
        972 524 8714
        [email protected]

        ____________________
        "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

        Comment


          #5
          Re: Xdialog will not close before report prints

          Try,

          'Date Created: 20-Jan-2011 01:26:47 PM
          'Last Updated: 20-Jan-2011 02:00:15 PM
          'Created By : E009933
          'Updated By : E009933
          'Run script: xdiag_start_end_empnum
          'script_play("xdiag_start_end_empnum")
          'Create an XDialog dialog box to prompt for parameters.
          trace.clear()
          DIM GLOBAL vstartdate as D
          DIM GLOBAL venddate as D
          DIM GLOBAL varC_result as C
          DIM GLOBAL vempnum as C
          Dim Global Printflag As L
          var->vstartdate={}
          var->venddate = {}
          var->vempnum=""
          var->Printflag = .F.
          dlg_title = "Enter Selection for Report"
          heading_string = "Enter Date Range"
          heading_string2 = "Enter Employee Number- Dont forget the Dashes"
          heading_string3 = "Example 05-1100-0"
          ok_button_label = "&OK"
          cancel_button_label = "&Cancel"
          Delete XdialogStyle
          dim XDialogStyle as p
          XDialogStyle.AccentColor = "White"
          XDialogStyle.Color = "#153+204+255"
          varC_result = ui_modeless_dlg_box(dlg_title,<<%dlg%
          {Windowstyle=Gradient Horizontal Bottom}
          {region}
          {text=55,1:heading_string};
          {endregion};
          {region}
          Enter Start date:| [%DATE;P=popup.calendar(dtoc(vstartdate));I=popup.calendar%.30vstartdate!vstartdate_*];
          Enter Ending date:| [%DATE;P=popup.calendar(dtoc(venddate));I=popup.calendar%.30venddate!venddate_*];
          {endregion};
          {line=1,0};
          {region3}
          {text=35,1:heading_string2};
          {text=35,1:heading_string3};
          Enter Employee Number: [.20vempnum!vempnum];
          {endregion3};
          {line=1,0};
          {region}
          <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
          {endregion};
          %dlg%,<<%code%
          if left(a_dlg_button,11) = "vstartdate_" then
          if a_dlg_button = "vstartdate_killfocus" then
          var->vstartdate = ctod(dtoc(vstartdate))
          end if
          var->printflag = .F.
          a_dlg_button = ""
          end if
          if left(a_dlg_button,9) = "venddate_" then
          if a_dlg_button = "venddate_killfocus" then
          var->venddate = ctod(dtoc(venddate))
          end if
          var->printflag = .F.
          a_dlg_button = ""
          end if
          if left(a_dlg_button,7) = "vempnum" then
          if a_dlg_button = "vempnum_killfocus" then
          var->vempnum = vempnum
          end if
          var->printflag = .F.
          a_dlg_button = ""
          end if
          if a_dlg_button = "OK" then
          ' a_dlg_button = ""
          If var->vstartdate <> {} .and. var->venddate <> {} .and. var->vempnum <> "" then
          var->printflag = .T.
          trace.WriteLn("Printflag ="+ printflag)
          trace.WriteLn("Beginning Date ="+ vstartdate)
          trace.WriteLn("Ending Date ="+ venddate)
          trace.WriteLn("Employee Number ="+ vempnum)
          ui_modeless_dlg_close(dlg_title)

          else
          code = UI_OK + UI_QUESTION_SYMBOL
          ui_msg_box("Question", "Fields cannot be Blank? ", code)
          ui_modeless_dlg_close(dlg_title)
          end if
          end if
          if a_dlg_button = "CANCEL" then
          a_dlg_button = ""
          trace.WriteLn("Beginning Date ="+ vstartdate)
          trace.WriteLn("Ending Date ="+ venddate)
          trace.WriteLn("Employee Number ="+ vempnum)
          var->printflag = .F.
          ui_modeless_dlg_close(dlg_title)
          end if

          %code%)
          if var->printflag = .T. then
          'Preview a report, label, letter, form or browse layout. You can specify which records to preview.
          query.filter = "(Entrydate >= Var->vstartdate ) .and. (Entrydate <= Var->venddate ) .and. (Empnum = Var->vempnum )"
          query.order = "recno()"
          'replace variables in the filter with their actual values
          query.filter = convert_expression(query.filter,"V")
          'Prompt user whether to print, or preview the layout. Set default to Preview
          prompt_result = ui_get_print_or_preview("Preview ")
          If prompt_result = "Print" then
          :Report.Print("Employee Hours4",query.filter,query.order)
          Else if prompt_result = "Preview" then
          :Report.Preview("Employee Hours4",query.filter,query.order)
          End if
          end if
          I can't fully test as I do not have a report built.

          I would also try to trap the end date must be after to start date and return the user to any blank field if it is not completed rather than exit
          -----------------------------------------------
          Regards
          Mark Pearson
          [email protected]
          Youtube channel
          Website

          Comment


            #6
            Re: Xdialog will not close before report prints

            Still no luck
            Just replace the print routine with a UI message box.

            If I take the if statement out ( If print flag = .T. in the print routine the message box pops up before the the xdialog shows.

            I cannot get the xdialog to open, then close and then do the message box.
            Also the printflag variable does not carry over to the message mox.

            Comment


              #7
              Re: Xdialog will not close before report prints

              Attached jpg
              This is what I am getting

              The report shows but the xdialog will not close until I exit the preview.

              I even changed modeless to modal
              still no luck.

              Charlie crimmel

              Comment


                #8
                Re: Xdialog will not close before report prints

                Not sure what is going on in your script, but I don't see the same problem here.

                Here's a sample script that you can import into AlphaSports.

                It displays an xdialog, waits for the user to select a customer, then previews a report filtered to that customer.

                Hope it helps.

                Comment


                  #9
                  Re: Xdialog will not close before report prints

                  Charlie,

                  We use x-dialog all the time to prompt for parameters then print reports. Never had the issue you're showing. I don't use modeless dialogs, but I don't see how that is an issue. Below is an example of how we're prompting for parameters, then, after the x-dialog closes, we print the appropriate report.

                  I hope it helps...

                  Code:
                  'Create an XDialog dialog box to prompt for parameters.
                  'variables "agency", "level" and "whereto" are Global variables set at database startup.
                  DIM SHARED choice as C
                  DIM SHARED ar_select as C
                  DIM SHARED Name as C
                  choice = ""
                  Name = ""
                  ar_select = ""
                  DIM SHARED varC_result as C
                  heading_string1 = "Please make selections and click 'OK'"
                  Heading_string2 = vg_case_no+" - "+vl_clname
                  heading_string = heading_string1+crlf()+"     "+heading_string2
                  ok_button_label = "&OK"
                  cancel_button_label = "&Cancel"
                  varC_result = ui_dlg_box(agency+" "+whereto,<<%dlg%
                  {region}
                  {text=45,2:heading_string};
                  {endregion};
                  {region}
                  {region}Please Select EBT Action:{endregion};
                  {region}     (choice:Video)|(choice:Repin)|(choice:Damaged)|(choice:Lost/Stolen);{endregion};
                  ;
                  {region}Is this a Client or Authorized Rep:{endregion};
                  {region}     (ar_select:Client)|(ar_select:Authorized Rep);{endregion};
                  {condition=(ar_select="Authorized Rep")}
                  {region}
                  Please Enter Authorized Rep Name: [.30Name];
                  {endregion};
                  {condition=.T.}
                  ;
                  {endregion};
                  {line=1,0};
                  {region}
                  <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
                  {endregion};
                  %dlg%)
                  if varC_result <> "OK"
                  	ui_msg_box(agency,"Action cancelled at user request")
                  	goto endit
                  end if
                  if choice = "" .or. ar_select = "" .or. (ar_select = "Authorized Rep" .and. name = "")
                  	ui_msg_box(agency,"Not enough information was entered, cannot continue")
                  	goto endit
                  end if
                  'determine checkboxes
                  select 
                  	case choice = "Video"
                  		video = "X"
                  	case choice = "Repin"
                  		repin = "X"
                  	case choice = "Damaged"
                  		damage = "X"
                  	case choice = "Lost/Stolen"
                  		lost = "X"
                  	case else
                  		'do nothing
                  end select
                  'determine if A/R
                  if ar_select = "Authorized Rep"
                  	if name <> ""
                  		ar = "X"
                  		ar_name = ut(name)
                    	  else
                    	  	ui_msg_box(agency,"Authorized Rep not entered, cannot continue")
                    	  	goto endit
                  	end if  	 		
                    else
                    	ar = ""
                    	ar_name = ""
                  end if
                  filt = "ssn = [varC->ssn]"
                  query.filter = replace_parameters(filt,local_variables())
                  query.order = ""
                  if level = "A"
                  	:Report.Preview("EBT Card Receipt",Query.filter,Query.order)
                  	end
                    else
                    	:Report.Print("EBT Card Receipt",Query.filter,Query.order)
                  	sleep(1)
                  	:Report.Print("CLIENT INFORMATION SHEET",query.filter,query.order)
                  end if
                  Tom

                  Comment


                    #10
                    Re: Xdialog will not close before report prints

                    Well I finally got it working.

                    Tom Henkel.-When I looked at your code I did not see
                    %dlg%,<<%code% and %code%)
                    When I removed these from my code It just skipped the dialog and went straight to print.
                    So I put the code back in.

                    I looked at some of the code that Selwyn wrote and he had the print routine after the %code%).

                    So I moved the print routine outside the code.
                    If I put the filters in the print routine it still would not work so I put the filters on the Report Select Data and it seems to work.
                    Thanks for everyones help.
                    Charlie Crimmel

                    Comment


                      #11
                      Re: Xdialog will not close before report prints

                      Charlie,
                      In my example, I didn't have a %code% section.

                      See RED for <<dlg

                      Code:
                      'Create an XDialog dialog box to prompt for parameters.
                      'variables "agency", "level" and "whereto" are Global variables set at database startup.
                      DIM SHARED choice as C
                      DIM SHARED ar_select as C
                      DIM SHARED Name as C
                      choice = ""
                      Name = ""
                      ar_select = ""
                      DIM SHARED varC_result as C
                      heading_string1 = "Please make selections and click 'OK'"
                      Heading_string2 = vg_case_no+" - "+vl_clname
                      heading_string = heading_string1+crlf()+"     "+heading_string2
                      ok_button_label = "&OK"
                      cancel_button_label = "&Cancel"
                      varC_result = ui_dlg_box(agency+" "+whereto,[COLOR="Red"][B]<<%dlg%[/B][/COLOR]
                      {region}
                      {text=45,2:heading_string};
                      {endregion};
                      {region}
                      {region}Please Select EBT Action:{endregion};
                      {region}     (choice:Video)|(choice:Repin)|(choice:Damaged)|(choice:Lost/Stolen);{endregion};
                      ;
                      {region}Is this a Client or Authorized Rep:{endregion};
                      {region}     (ar_select:Client)|(ar_select:Authorized Rep);{endregion};
                      {condition=(ar_select="Authorized Rep")}
                      {region}
                      Please Enter Authorized Rep Name: [.30Name];
                      {endregion};
                      {condition=.T.}
                      ;
                      {endregion};
                      {line=1,0};
                      {region}
                      <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
                      {endregion};
                      [COLOR="Red"][B]%dlg%)[/B][/COLOR]
                      if varC_result <> "OK"
                      	ui_msg_box(agency,"Action cancelled at user request")
                      	goto endit
                      end if
                      if choice = "" .or. ar_select = "" .or. (ar_select = "Authorized Rep" .and. name = "")
                      	ui_msg_box(agency,"Not enough information was entered, cannot continue")
                      	goto endit
                      end if
                      'determine checkboxes
                      select 
                      	case choice = "Video"
                      		video = "X"
                      	case choice = "Repin"
                      		repin = "X"
                      	case choice = "Damaged"
                      		damage = "X"
                      	case choice = "Lost/Stolen"
                      		lost = "X"
                      	case else
                      		'do nothing
                      end select
                      'determine if A/R
                      if ar_select = "Authorized Rep"
                      	if name <> ""
                      		ar = "X"
                      		ar_name = ut(name)
                        	  else
                        	  	ui_msg_box(agency,"Authorized Rep not entered, cannot continue")
                        	  	goto endit
                      	end if  	 		
                        else
                        	ar = ""
                        	ar_name = ""
                      end if
                      filt = "ssn = [varC->ssn]"
                      query.filter = replace_parameters(filt,local_variables())
                      query.order = ""
                      if level = "A"
                      	:Report.Preview("EBT Card Receipt",Query.filter,Query.order)
                      	end
                        else
                        	:Report.Print("EBT Card Receipt",Query.filter,Query.order)
                      	sleep(1)
                      	:Report.Print("CLIENT INFORMATION SHEET",query.filter,query.order)
                      end if
                      It probably wasn't a great example, but it does close before we print the reports.

                      I never put the report printing into the code. I use the code to make sure the variables set in the dialog are correct, then once I am sure they are, I get out of the code. I then, in x-basic, use the variables to set up the report.

                      Tom

                      Comment


                        #12
                        Re: Xdialog will not close before report prints

                        Charlie,

                        Here is another example. I built a new xdialog based on what you are trying to achieve and also modified the report filter. It also traps empty fields and invalid date range. Hope it helps

                        DIM SHARED dat1 as D
                        DIM SHARED dat2 as D
                        DIM SHARED Eno as N
                        DIM SHARED varC_result as C
                        dat1 = {}
                        dat2 = {}
                        ok_button_label = "&Print"
                        cancel_button_label = "&Cancel"
                        varC_result = ui_dlg_box("Alpha Five",<<%dlg%
                        {region}
                        Start Date:| [%DATE;P=popup.calendar(dtoc(dat1));I=popup.calendar%.20dat1!dat1_*];
                        End date:| [%DATE;P=popup.calendar(dtoc(dat2));I=popup.calendar%.20dat2!dat2_*];
                        Employee Number:| [%z%.10Eno];
                        {endregion};
                        {line=1,0};
                        {region}
                        <*15=ok_button_label!OK> <15=cancel_button_label!CANCEL>
                        {endregion};
                        %dlg%,<<%code%
                        if left(a_dlg_button,5) = "dat1_" then
                        if a_dlg_button = "dat1_killfocus" then
                        dat1 = ctod(dtoc(dat1))
                        end if
                        a_dlg_button = ""
                        end if

                        if left(a_dlg_button,5) = "dat2_" then
                        if a_dlg_button = "dat2_killfocus" then
                        dat2 = ctod(dtoc(dat2))
                        end if
                        a_dlg_button = ""
                        end if
                        iF a_dlg_button = "OK" .and. dat1 = {} then
                        a_dlg_button = ""
                        ui_msg_box("Nothing entered","Must insert a start date")
                        ui_dlg_ctl_goto("Alpha Five","dat1")
                        end if
                        iF a_dlg_button = "OK" .and. dat2 = {} then
                        a_dlg_button = ""
                        ui_msg_box("Nothing entered","Must insert an end date")
                        ui_dlg_ctl_goto("Alpha Five","dat2")
                        end if
                        iF a_dlg_button = "OK" .and. eno = 0 then
                        a_dlg_button = ""
                        ui_msg_box("Nothing entered","Must insert an employee number")
                        ui_dlg_ctl_goto("Alpha Five","eno")
                        end if
                        iF a_dlg_button ="OK" .and. dat1 > dat2 then
                        a_dlg_button = ""
                        ui_msg_box("Invalid date","End date must be greater than or equal to start date")
                        ui_dlg_ctl_goto("Alpha Five","dat2")
                        end if

                        %code%)

                        If varC_result = "CANCEL" .or. varC_result = "" then
                        end
                        end if

                        query.filter = "between(Entrydate,Var->Dat1,Var->Dat2) .and. (Empnum = Var->eno )"
                        query.order = "recno()"
                        'replace variables in the filter with their actual values
                        query.filter = convert_expression(query.filter,"V")

                        'Prompt user whether to print, or preview the layout. Set default to Preview
                        prompt_result = ui_get_print_or_preview("Preview ")
                        If prompt_result = "Print" then
                        :Report.Print("Employee Hours4",query.filter,query.order)
                        Else if prompt_result = "Preview" then
                        :Report.Preview("Employee Hours4",query.filter,query.order)
                        End if

                        -----------------------------------------------
                        Regards
                        Mark Pearson
                        [email protected]
                        Youtube channel
                        Website

                        Comment


                          #13
                          Re: Xdialog will not close before report prints

                          I also just noted that you use a Chr for the empnum. I used a numeric. So if you need to change to chr then you may need to change the report filter as well. This variable may need to be trimmed of spaces etc.
                          -----------------------------------------------
                          Regards
                          Mark Pearson
                          [email protected]
                          Youtube channel
                          Website

                          Comment

                          Working...
                          X