Temporarily setting control default data from form

  • Thread starter Thread starter Fred Boer
  • Start date Start date
F

Fred Boer

Hello!

I have a school library catalogue application, and I'm working on my data
entry / cataloguing form. As I'm using it (what's the expression? "As I eat
my own dog food?"<g>), I'm finding problems and see ways it could be
improved...

In my library collection there are braille books. A single braille book
might be composed of several volumes. Each volume is catalogued separately.
When cataloguing a book like this, the data for each volume is identical
except for one field: "VolumeNumber". What I *think* I would like to do
(although I am open to suggestions!) is to have a command button which I
could click after entering the data for the first volume. This button would
store all of the values in all the relevant controls as the default values
for these controls (with the exception of the VolumeNumber textbox). Then, I
would only have to enter a new volume number to catalogue subsequent
volumes. After all the volumes are entered, I would click on the button
again to set the default values back to null.

The following code doesn't give me an error message, but doesn't set the
default value either. What am I doing wrong?

Private Sub cmdSetDefaults_Click()
If Not IsNull(Me.cboTitle) Then
Me.cboTitle.SetFocus
Me.cboTitle.DefaultValue = Me.cboTitle

End If
End Sub

Thanks!
Fred Boer

P.S. I suppose the best solution would be to loop through the controls on
the form, but I'm taking baby steps here <g>
 
Fred Boer said:
Hello!

I have a school library catalogue application, and I'm working on my
data entry / cataloguing form. As I'm using it (what's the
expression? "As I eat my own dog food?"<g>), I'm finding problems and
see ways it could be improved...

In my library collection there are braille books. A single braille
book might be composed of several volumes. Each volume is catalogued
separately. When cataloguing a book like this, the data for each
volume is identical except for one field: "VolumeNumber". What I
*think* I would like to do (although I am open to suggestions!) is to
have a command button which I could click after entering the data for
the first volume. This button would store all of the values in all
the relevant controls as the default values for these controls (with
the exception of the VolumeNumber textbox). Then, I would only have
to enter a new volume number to catalogue subsequent volumes. After
all the volumes are entered, I would click on the button again to set
the default values back to null.

The following code doesn't give me an error message, but doesn't set
the default value either. What am I doing wrong?

Private Sub cmdSetDefaults_Click()
If Not IsNull(Me.cboTitle) Then
Me.cboTitle.SetFocus
Me.cboTitle.DefaultValue = Me.cboTitle

End If
End Sub

Thanks!
Fred Boer

P.S. I suppose the best solution would be to loop through the
controls on the form, but I'm taking baby steps here <g>

Try it like this, Fred:

If Not IsNull(Me.cboTitle) Then
Me.cboTitle.DefaultValue = """" & Me.cboTitle """"
End If

The DefaultValue property is a text property that must contain the
representation of a literal string that will be evaluated and assigned
to the control. Hence what must appear to be "extra quotes".
 
Dear Dirk:

Thanks! Of course! I need to make it a literal string; it seems obvious -
now that you've said it. <g>

Just as an aside... I couldn't seem to make the code you gave me work, but
when I used "fncQuoted", it worked fine.

Me.cboTitle.DefaultValue = fncQuoted(Me.cboTitle) 'Works...

Public Function fncQuoted(StringToQuote As String) As String
fncQuoted = Chr(34) & Replace(StringToQuote, Chr(34), """""", , , _
vbBinaryCompare) & Chr(34)
End Function


Thanks again, Dirk!

Fred
 
Oh, wait, I think I got it - I needed another ampersand...

Me.cboTitle.DefaultValue = """" & Me.cboTitle & """"

Cheers!
Fred
 
No problem, Dirk! I'm sure you only did it to keep me on my toes! ;)

BTW, I've managed to set up these "Set Current As Default/Set Defaults to
Null" buttons, and they seem to work just great. My cataloguing time for
multi-volume materials has been reduced by more than half! This Access stuff
is *so* much fun when it works! I feel so powerful! Just wait'll I show my
boss... oh, wait, he's not really interested... but just wait'll I show my
co-workers.. oh, wait.. thev aren't interested either. And my students are
definitely not interested... And my wife and kids... sigh... Oh well... It's
fun for me, at least! <g>

Cheers!
Fred
 
Fred Boer said:
No problem, Dirk! I'm sure you only did it to keep me on my toes! ;)

Oh, of course. ;-)
BTW, I've managed to set up these "Set Current As Default/Set
Defaults to Null" buttons, and they seem to work just great. My
cataloguing time for multi-volume materials has been reduced by more
than half!

Great! An idea just occurred to me: do you use this feature only for
cataloguing multi-volume works? If so, you might be able to speed up
the process yet further by having an unbound text box where you just
enter the number of volumes, and code in the AfterUpdate event
automatically creates the desired number of records, copying the current
record as many times as needed and just changing the "VolumeNumber"
field for each new copied record.
This Access stuff is *so* much fun when it works!

Ain't it, though? I've always felt that the appeal of programming is
the desire to work magic, and Access is a heck of a magic wand.
I feel
so powerful! Just wait'll I show my boss... oh, wait, he's not really
interested... but just wait'll I show my co-workers.. oh, wait.. thev
aren't interested either. And my students are definitely not
interested... And my wife and kids... sigh... Oh well... It's fun for
me, at least! <g>

Welcome to the world of the software developer.
 
Hi Dirk!

That's a good idea! However, I *think* it would be rather complicated
because "Author" information is kept in a separate table, and an
intersection table links books to authors. Consequently, the "book
information" record has to be created and saved before the "author
information" record can be created and linked to the book using the
intersecting table. The current workflow is: enter book information>save
record>enter author information>save author record>print labels.

In addition, (if you recall), you've helped me create code to ensure that an
author must be linked to a book before another new book record can be
created...

However, I'm sure it could be done somehow; let me think about it and see
how far I can get with the idea myself!
Ain't it, though? I've always felt that the appeal of programming is
the desire to work magic, and Access is a heck of a magic wand.

Absolutely! And the more I try to do myself, the more respect I have for
*real* programmers!
Welcome to the world of the software developer.

Thanks... where's the nearest beach bar?

Fred
 
Fred Boer said:
In addition, (if you recall), you've helped me create code to ensure
that an author must be linked to a book before another new book
record can be created...

Yes, now that you mention it, I remember.
However, I'm sure it could be done somehow; let me think about it and
see how far I can get with the idea myself!

Have fun.
 
Back
Top