Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying the default Access popup dialog box 5

Status
Not open for further replies.
Oct 24, 2002
512
US
Does anybody know how to change the default dialog box? I know how to create dialog boxes from scratch but sometimes it seems like it would be quicker to just change some stuff on the default message box. I simply don't have a clue how to do it. Any ideas?

Thanks!
Ann
 
What exacly is it you want to change... You can change the title, and a couple of things about the buttons... But much you can't change(Thank I know of any way)...

Since you know how to make one from scratch, might I suggest that you make a sub/function that makes one with arguments, that does what ever you need, and is as changable as you want...

Just my humble thoughts...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
I don't realy understand how I helped... but your welcome:)

Thanks for the star...

If you followed my suggestion by making a function to do it, how about sharing it with us?? So we all may reap the goodness of your solution ;-)

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
I've played with this idea a bit but, so far, no luck. Maybe I'm just being lazy (not wanting to design a message box every single time) but I still think you're onto something here and I haven't given up yet. If/when I come up with something I'll surely post it.

Maybe someone more experienced than I am will address this???
 
You seem to be pretty good with code... make a function that has optional options, just like the msgbox function...

then create your message box based off of the options put in...

If you want to control size and all, then put in there optional things...

assume a standard size for it, but if the user puts some thing in the calling for this, then use that...

if you give me some example code to make a box, I can try to put together a function for you...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
junior1544, haven't been able to get back to this yet. Just wanted to let you know I appreciate the offer of help.
Ann
 
junior1544[/],

If you want to participate in Ann's exercise, the 'box' is just a modal form, so there is no need for a specific version. The necessary part would be to have the 'shopping list' of features. A START would be to just emulate the existing msgbox, as at least most of the functionallity of that would probably be desired. Other than the Icons (which must be available SOMEWHERE) the msg box should be easily emulated.

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Thanks Michael...

Hadn't thought of that...

I'll see what i can do:)
--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
I just read a very interesting post by Rick Sprague. The default dialog box I was talking about was the one that pops up as a result of running a parameter query. (I see now that I never specified that "minor" detail. Sorry!) Anyway, thought you might be interested in taking a look at what he has to say:

Dec 9, 2002
No, I'm afraid there's no global switch to turn off a prompt for parameters. You see, the prompt doesn't really come out of Access code at all. Access just builds the SQL statement in all these scenarios and submits it to Jet for execution. When Jet finds something it can't recognize, it passes it to an interface call the "Visual Basic Expression Service" to see if VBA can figure it out. It's the Expression Service that prompts for the value, and that's two levels down from the Access code, so Access has no control over whether the prompt happens. (Except that it's Access that hooks up the Expression Service for Jet to use in the first place, but that happens when Access starts up, so if you disabled it, it would apply globally and you wouldn't be able to use parameters at all, anywhere. You wouldn't even be able to use references to form fields in queries, in fact!)
Rick Sprague


 
ahh, see, That completly changes all of it...

Your getting a prompt for a value because the sql may not be formatted corectly... (or there's an other discrepency in the code...)

How about you post your code here and we'll see what we can do to make it work the way you want to...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
James, it's not an error. Ya know, when you create a parameter query you get that default dialog box.

For example, I might have a form or report for a work order based on a query that shows all kinds of information but I just want a particular work order. The criteria in my query (below the WONumber field) would probably say something like "[Enter the WO #].

When the user opens the form or report, he gets a "default" dialog box that has the caption "Enter parameter value" then it shows my text " Enter the WO #" and then has an empty field for user input.

I'd really like to substitute the "Enter parameter value" caption with my own but apparently I can't get to it to change it.

Oh, well. (Sigh!)
 
but you CAN set up the overall process to programmatically include parameter(s) for the query. then, you can use any number of variations on the dialog, supplying your home-made dialog box(es), grabbing the parameter(s) from form controls, doing some calculations to derive parameter(s), ...


MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Oh, dear! Michael are you giving me false hopes? Please, please, give a little more info.
Ann
 
Hopefully not false hope(s). Here is ONE example of supplying a parameter to a query from code:

Code:
Public Function basNumWeeks(DateIn As Date) As String

    'Michael Red     7/3/2001

    'Calculates the number of Weeks from The Fiscal Year StartDate to DateIn
    'Requires the table to have the fiscal Year data

    Dim dbs As dao.Database
    Dim rst As Recordset
    Dim qdf As dao.QueryDef
    
    Set dbs = CurrentDb
    Set qdf = dbs.QueryDefs("qryFiscYr")

    Dim StDt As Date            'StartDate
    Dim FiscYr As String        'Fiscal Year from Table
    Dim PayDays As Integer      'Intermediate accumulator for the Number of Weeks
    Dim Perds As Integer
    Dim WkNum As Integer

    'First find the Fiscal Year record in the table
    qdf.Parameters("DateIn") = DateIn
    Set rst = qdf.OpenRecordset()
    If (rst.EOF) Then
        'Error Exit w/ empty String
     Else
        StDt = rst!StDt
        FiscYr = rst!FiscYr
    End If
    
    PayDays = DateDiff("ww", StDt, DateIn, vbSunday)
    Perds = (PayDays \ 4) + 1
    WkNum = PayDays Mod 4
    
    basNumWeeks = FiscYr & ", " & Trim(str(Perds)) & ", " & Trim(str(WkNum))

End Function

I realize that your situation will be somewhat different, as you will (now) still require your custom dialog box to input the parameter value, and you are using the results to open a form / report, so some additional details need to be considered, as well as changing the litterals to suit your objects. This is ONLY to illustrate that parameters may be supplied via alternate methods.

I actually seldom use the process you are describing directly, but generally manipulate the form / report recordsorce object prior to instantiating the object to avoid this, but it can be a useful technique.

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Michael, thanks so much for the quick response. I'm home sick today AND I'm new to VBA code so I probably won't be able to absorb this until later today (or tomorrow). This is a great site and I really appreciate folks like you that make it so GREAT.
Ann
 
James & Micheal, just wanted to say thanks again for your input. I'm not over this yet; it's just kind of a "nice to have" as opposed to a "got to have" at work.

You may hear back from me yet. (I hope you don't mind.) But for now, I'm going to bow out of this post (after having printed it out, of course!).

Thanks again.

Ann
 
Ann,

I have to admit I have become intrigued by this thread and have been playing about with the following

Function dBox(strCaption As String) As String
Dim frm As Form, ctl As Control, mdl As Module, lngReturn As Long

BooldBox = False
On Error GoTo Error_dBox
' Create new form.
Set frm = CreateForm
frm.Caption = strCaption
frm.ScrollBars = 0 'Neither
frm.Visible = True
frm.Modal = True
frm.NavigationButtons = False

' Create command button on form.
Set ctl = CreateControl(frm.NAME, acCommandButton, , , , 1000, 1000)
ctl.Caption = "Click here"
' Return reference to form module.
Set mdl = frm.Module
' Add event procedure.
lngReturn = mdl.CreateEventProc("Click", ctl.NAME)

' Insert text into body of procedure.
mdl.InsertLines lngReturn + 1, vbTab & "MsgBox ""Way cool!""" & vbCrLf & "booldbox = true"
Set ctl = CreateControl(frm.NAME, acCommandButton, , , , 2000, 2000)
ctl.Caption = "Exit"
' Return reference to form module.
Set mdl = frm.Module
'Add event procedure.
lngReturn = mdl.CreateEventProc("Click", ctl.NAME)

' Insert text into body of procedure.
mdl.InsertLines lngReturn + 1, vbTab & "DoCmd.Close acForm, me.NAME, acSaveNo"

'Open dBox
DoCmd.OpenForm frm.NAME, acNormal, , , , acDialog

Exit_dBox:
Exit Function

Error_dBox:
MsgBox Err & " :" & Err.DESCRIPTION
Resume Exit_dBox
End Function

In theory this could set up a dialog box, parameter form on the fly (from a global module). So far it fires up a box with 2 buttons, the problem I am having though is that its not staying modal enough for me!!

Let me know if you get any joy.

Cheers

Andy
 
Interesting. And it (kinda?) works. The problem, as I see it is that you are setting booldbox in both the procedure which creates the new form and in the (new) forms procedures. To reasonably do this, you need to include a specific reference to where ever it is really defined. this brings up the 'fact' that it booldbox isn't (defined).

With out SOME correction here, the (new) form doesn't close, which causes additional thinggys to go/be awry.

An EASY fix is to just delete the code which references the fool (or is that 'bool'?) thing. Then, the procedure may be run from where-ever, generate the form and it is available to get the 'hello world, re-invented message. You are correct, however that it is aparently NOT a modal form. I suspect this is simply because the thinnggyyyy hasn't been saved, so some properties are not jelled sufficiently - but this is JUST a guess,

MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
Hey all,

interesting subject. What I like to do to get custom dialog boxes as query parameter is that :

Instead of of typing "[Enter the WO #]" as the criteria string I put a function name like EnterWO(). Then, in that function, you can call any saved form you like to input the parameter or even the default access input box (on witch you can change the caption, witch was the point of this thread).

You could also simply use MichealRed function as the criteria string directly in the query.

I hope this will give you some ideas!





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top