PC Review


Reply
Thread Tools Rate Thread

Create datasheet in MDE

 
 
DRedDog
Guest
Posts: n/a
 
      18th May 2010
My application creates a datasheet on the fly. Users make a selection from a
set parameters including column names, sort order, etc and the code
populates a querydef with the set of columns selected by the user.

This works fine in an MDB. The equivalent MDE crashes - "That command isn't
available in an MDE database"

Please tell me how to add/delete columns from a querydef in an MDE file?

DT

 
Reply With Quote
 
 
 
 
Tom van Stiphout
Guest
Posts: n/a
 
      19th May 2010
On Tue, 18 May 2010 12:57:59 -0400, "DRedDog" <(E-Mail Removed)>
wrote:

What command?
Surely MDE would allow you to create a sql statement and assign that
to the RecordSource of a form?

-Tom.
Microsoft Access MVP


>My application creates a datasheet on the fly. Users make a selection from a
>set parameters including column names, sort order, etc and the code
>populates a querydef with the set of columns selected by the user.
>
>This works fine in an MDB. The equivalent MDE crashes - "That command isn't
>available in an MDE database"
>
>Please tell me how to add/delete columns from a querydef in an MDE file?
>
>DT

 
Reply With Quote
 
DRedDog
Guest
Posts: n/a
 
      19th May 2010
Thanks for your response. Assigning the SQL to the form's recordsource
property is not the problem - it is adding/deleting controls that the MDE
database objects to.
Troubleshooting the MDE is a little awkward but I think the offending line
might be -:

DeleteControl strForm, Forms(strForm).Controls(0).name

This is the sub that creates the datasheet form in the mdb file.

Sub MakeRptDataForm(strForm As String, strQuery As String)
Dim ctl As Control
Dim fld As Field
Dim qdf As DAO.QueryDef
Dim db As DAO.Database
Dim sngTop As Single

On Error GoTo Err_MakeRptDataForm
DoCmd.OpenForm strForm, acDesign, , , , acHidden

Do Until Forms(strForm).Controls.Count = 0
DeleteControl strForm, Forms(strForm).Controls(0).name
Loop

Forms(strForm).RecordSource = strQuery
Set db = CurrentDb
Set qdf = db.QueryDefs(strQuery)
sngTop = 0
For Each fld In qdf.Fields
CreateControl strForm, acTextBox, acDetail, , fld.name, 0, sngTop
sngTop = sngTop + 0.725 * 567
Next fld

For Each ctl In Forms(strForm).Controls
If ctl.ControlType = acTextBox Then
ctl.name = ctl.ControlSource
End If
Next ctl

Exit_MakeRptDataForm:
DoCmd.SetWarnings False
DoCmd.Close acForm, Forms(strForm).name
DoCmd.SetWarnings True
Exit Sub

Err_MakeRptDataForm:
Select Case Err
Case Else
MsgBox Err.Description
'Stop
Resume Exit_MakeRptDataForm

End Select
End Sub

"Tom van Stiphout" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Tue, 18 May 2010 12:57:59 -0400, "DRedDog" <(E-Mail Removed)>
> wrote:
>
> What command?
> Surely MDE would allow you to create a sql statement and assign that
> to the RecordSource of a form?
>
> -Tom.
> Microsoft Access MVP
>
>
>>My application creates a datasheet on the fly. Users make a selection from
>>a
>>set parameters including column names, sort order, etc and the code
>>populates a querydef with the set of columns selected by the user.
>>
>>This works fine in an MDB. The equivalent MDE crashes - "That command
>>isn't
>>available in an MDE database"
>>
>>Please tell me how to add/delete columns from a querydef in an MDE file?
>>
>>DT


 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      19th May 2010
Create a form that has the maximum number of text boxes you think you'll
need, and simply set the Visible property to False for the unneeded ones.

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"DRedDog" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks for your response. Assigning the SQL to the form's recordsource
> property is not the problem - it is adding/deleting controls that the MDE
> database objects to.
> Troubleshooting the MDE is a little awkward but I think the offending line
> might be -:
>
> DeleteControl strForm, Forms(strForm).Controls(0).name
>
> This is the sub that creates the datasheet form in the mdb file.
>
> Sub MakeRptDataForm(strForm As String, strQuery As String)
> Dim ctl As Control
> Dim fld As Field
> Dim qdf As DAO.QueryDef
> Dim db As DAO.Database
> Dim sngTop As Single
>
> On Error GoTo Err_MakeRptDataForm
> DoCmd.OpenForm strForm, acDesign, , , , acHidden
>
> Do Until Forms(strForm).Controls.Count = 0
> DeleteControl strForm, Forms(strForm).Controls(0).name
> Loop
>
> Forms(strForm).RecordSource = strQuery
> Set db = CurrentDb
> Set qdf = db.QueryDefs(strQuery)
> sngTop = 0
> For Each fld In qdf.Fields
> CreateControl strForm, acTextBox, acDetail, , fld.name, 0, sngTop
> sngTop = sngTop + 0.725 * 567
> Next fld
>
> For Each ctl In Forms(strForm).Controls
> If ctl.ControlType = acTextBox Then
> ctl.name = ctl.ControlSource
> End If
> Next ctl
>
> Exit_MakeRptDataForm:
> DoCmd.SetWarnings False
> DoCmd.Close acForm, Forms(strForm).name
> DoCmd.SetWarnings True
> Exit Sub
>
> Err_MakeRptDataForm:
> Select Case Err
> Case Else
> MsgBox Err.Description
> 'Stop
> Resume Exit_MakeRptDataForm
>
> End Select
> End Sub
>
> "Tom van Stiphout" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> On Tue, 18 May 2010 12:57:59 -0400, "DRedDog" <(E-Mail Removed)>
>> wrote:
>>
>> What command?
>> Surely MDE would allow you to create a sql statement and assign that
>> to the RecordSource of a form?
>>
>> -Tom.
>> Microsoft Access MVP
>>
>>
>>>My application creates a datasheet on the fly. Users make a selection
>>>from a
>>>set parameters including column names, sort order, etc and the code
>>>populates a querydef with the set of columns selected by the user.
>>>
>>>This works fine in an MDB. The equivalent MDE crashes - "That command
>>>isn't
>>>available in an MDE database"
>>>
>>>Please tell me how to add/delete columns from a querydef in an MDE file?
>>>
>>>DT

>



 
Reply With Quote
 
DRedDog
Guest
Posts: n/a
 
      19th May 2010
Thank you, Douglas J. Steele. I will probably use the method you have
suggested if there is really no way to create/delete controls in the MDE.
But I am still hoping to find a way to do this.

DT

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote in message
news:(E-Mail Removed)...
> Create a form that has the maximum number of text boxes you think you'll
> need, and simply set the Visible property to False for the unneeded ones.
>
> --
> Doug Steele, Microsoft Access MVP
> http://www.AccessMVP.com/DJSteele
> (no e-mails, please!)
>
> "DRedDog" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Thanks for your response. Assigning the SQL to the form's recordsource
>> property is not the problem - it is adding/deleting controls that the MDE
>> database objects to.
>> Troubleshooting the MDE is a little awkward but I think the offending
>> line might be -:
>>
>> DeleteControl strForm, Forms(strForm).Controls(0).name
>>
>> This is the sub that creates the datasheet form in the mdb file.
>>
>> Sub MakeRptDataForm(strForm As String, strQuery As String)
>> Dim ctl As Control
>> Dim fld As Field
>> Dim qdf As DAO.QueryDef
>> Dim db As DAO.Database
>> Dim sngTop As Single
>>
>> On Error GoTo Err_MakeRptDataForm
>> DoCmd.OpenForm strForm, acDesign, , , , acHidden
>>
>> Do Until Forms(strForm).Controls.Count = 0
>> DeleteControl strForm, Forms(strForm).Controls(0).name
>> Loop
>>
>> Forms(strForm).RecordSource = strQuery
>> Set db = CurrentDb
>> Set qdf = db.QueryDefs(strQuery)
>> sngTop = 0
>> For Each fld In qdf.Fields
>> CreateControl strForm, acTextBox, acDetail, , fld.name, 0, sngTop
>> sngTop = sngTop + 0.725 * 567
>> Next fld
>>
>> For Each ctl In Forms(strForm).Controls
>> If ctl.ControlType = acTextBox Then
>> ctl.name = ctl.ControlSource
>> End If
>> Next ctl
>>
>> Exit_MakeRptDataForm:
>> DoCmd.SetWarnings False
>> DoCmd.Close acForm, Forms(strForm).name
>> DoCmd.SetWarnings True
>> Exit Sub
>>
>> Err_MakeRptDataForm:
>> Select Case Err
>> Case Else
>> MsgBox Err.Description
>> 'Stop
>> Resume Exit_MakeRptDataForm
>>
>> End Select
>> End Sub
>>
>> "Tom van Stiphout" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> On Tue, 18 May 2010 12:57:59 -0400, "DRedDog" <(E-Mail Removed)>
>>> wrote:
>>>
>>> What command?
>>> Surely MDE would allow you to create a sql statement and assign that
>>> to the RecordSource of a form?
>>>
>>> -Tom.
>>> Microsoft Access MVP
>>>
>>>
>>>>My application creates a datasheet on the fly. Users make a selection
>>>>from a
>>>>set parameters including column names, sort order, etc and the code
>>>>populates a querydef with the set of columns selected by the user.
>>>>
>>>>This works fine in an MDB. The equivalent MDE crashes - "That command
>>>>isn't
>>>>available in an MDE database"
>>>>
>>>>Please tell me how to add/delete columns from a querydef in an MDE file?
>>>>
>>>>DT

>>

>
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      19th May 2010
There is no way to do it. CreateControl (and presumably DeleteControl) will
not work in an MDE.

--
Doug Steele, Microsoft Access MVP
http://www.AccessMVP.com/DJSteele
(no e-mails, please!)

"DRedDog" <(E-Mail Removed)> wrote in message
news:O$1jS%(E-Mail Removed)...
> Thank you, Douglas J. Steele. I will probably use the method you have
> suggested if there is really no way to create/delete controls in the MDE.
> But I am still hoping to find a way to do this.
>
> DT
>
> "Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote in message
> news:(E-Mail Removed)...
>> Create a form that has the maximum number of text boxes you think you'll
>> need, and simply set the Visible property to False for the unneeded ones.
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://www.AccessMVP.com/DJSteele
>> (no e-mails, please!)
>>
>> "DRedDog" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Thanks for your response. Assigning the SQL to the form's recordsource
>>> property is not the problem - it is adding/deleting controls that the
>>> MDE database objects to.
>>> Troubleshooting the MDE is a little awkward but I think the offending
>>> line might be -:
>>>
>>> DeleteControl strForm, Forms(strForm).Controls(0).name
>>>
>>> This is the sub that creates the datasheet form in the mdb file.
>>>
>>> Sub MakeRptDataForm(strForm As String, strQuery As String)
>>> Dim ctl As Control
>>> Dim fld As Field
>>> Dim qdf As DAO.QueryDef
>>> Dim db As DAO.Database
>>> Dim sngTop As Single
>>>
>>> On Error GoTo Err_MakeRptDataForm
>>> DoCmd.OpenForm strForm, acDesign, , , , acHidden
>>>
>>> Do Until Forms(strForm).Controls.Count = 0
>>> DeleteControl strForm, Forms(strForm).Controls(0).name
>>> Loop
>>>
>>> Forms(strForm).RecordSource = strQuery
>>> Set db = CurrentDb
>>> Set qdf = db.QueryDefs(strQuery)
>>> sngTop = 0
>>> For Each fld In qdf.Fields
>>> CreateControl strForm, acTextBox, acDetail, , fld.name, 0, sngTop
>>> sngTop = sngTop + 0.725 * 567
>>> Next fld
>>>
>>> For Each ctl In Forms(strForm).Controls
>>> If ctl.ControlType = acTextBox Then
>>> ctl.name = ctl.ControlSource
>>> End If
>>> Next ctl
>>>
>>> Exit_MakeRptDataForm:
>>> DoCmd.SetWarnings False
>>> DoCmd.Close acForm, Forms(strForm).name
>>> DoCmd.SetWarnings True
>>> Exit Sub
>>>
>>> Err_MakeRptDataForm:
>>> Select Case Err
>>> Case Else
>>> MsgBox Err.Description
>>> 'Stop
>>> Resume Exit_MakeRptDataForm
>>>
>>> End Select
>>> End Sub
>>>
>>> "Tom van Stiphout" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> On Tue, 18 May 2010 12:57:59 -0400, "DRedDog" <(E-Mail Removed)>
>>>> wrote:
>>>>
>>>> What command?
>>>> Surely MDE would allow you to create a sql statement and assign that
>>>> to the RecordSource of a form?
>>>>
>>>> -Tom.
>>>> Microsoft Access MVP
>>>>
>>>>
>>>>>My application creates a datasheet on the fly. Users make a selection
>>>>>from a
>>>>>set parameters including column names, sort order, etc and the code
>>>>>populates a querydef with the set of columns selected by the user.
>>>>>
>>>>>This works fine in an MDB. The equivalent MDE crashes - "That command
>>>>>isn't
>>>>>available in an MDE database"
>>>>>
>>>>>Please tell me how to add/delete columns from a querydef in an MDE
>>>>>file?
>>>>>
>>>>>DT
>>>

>>
>>



 
Reply With Quote
 
David W. Fenton
Guest
Posts: n/a
 
      19th May 2010
"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_gmail.com> wrote in
news:(E-Mail Removed):

> There is no way to do it. CreateControl (and presumably
> DeleteControl) will not work in an MDE.


And, of course, even if it *did* work, after using it a few times,
the form would no longer be changeable, as the maximum number of
controls (700-something) has been used up.

In creating the Access replication conflict resolver for Access
2000, Michael Kaplan used the method of adding all the controls and
then hiding/showing them as needed. If that's good enough for a
genius like MichKa, it's good enough for me!

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Report using fields from Form's datasheet Gntlhnds Microsoft Access Reports 1 28th Apr 2010 04:44 AM
use selection from datasheet to create outlook distrib list =?Utf-8?B?RXp6aWU=?= Microsoft Access External Data 2 4th Nov 2006 06:55 AM
How to Create a Lookup for Record in a Subform (Not in Datasheet View) DOYLE60 Microsoft Access VBA Modules 0 5th Jan 2005 04:48 PM
How can I create a datasheet-like form? Dave Microsoft Access Forms 2 17th Mar 2004 05:23 AM
Using wizard to create 'datasheet' form David Microsoft Access Getting Started 2 16th Dec 2003 10:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:42 AM.