PC Review


Reply
Thread Tools Rate Thread

How can I make VB lookup a Text field to see if it is empty?

 
 
=?Utf-8?B?U3RldmVuSXBlay4=?=
Guest
Posts: n/a
 
      2nd Jul 2005
I have written the following, but if the "Edition_Number" field is empty, it
will store an empty record, how can I make it look at that field to see if
there is any text or not?
Private Sub Close_Edition_Number_Form_Click()
On Error GoTo Err_Close_Edition_Number_Form_Click

DoCmd.Save
DoCmd.Close

Exit_Close_Edition_Number_Form_Click:
Exit Sub

Err_Close_Edition_Number_Form_Click:
MsgBox Err.Description
Resume Exit_Close_Edition_Number_Form_Click

End Sub
Thank you in anticipation for your help in this matter.
 
Reply With Quote
 
 
 
 
Joerg Ackermann
Guest
Posts: n/a
 
      2nd Jul 2005
StevenIpek. wrote:

> I have written the following, but if the "Edition_Number" field is
> empty, it will store an empty record, how can I make it look at that
> field to see if there is any text or not?
> Private Sub Close_Edition_Number_Form_Click()
> On Error GoTo Err_Close_Edition_Number_Form_Click
>
> DoCmd.Save
> DoCmd.Close
>
> Exit_Close_Edition_Number_Form_Click:
> Exit Sub
>
> Err_Close_Edition_Number_Form_Click:
> MsgBox Err.Description
> Resume Exit_Close_Edition_Number_Form_Click
>
> End Sub
> Thank you in anticipation for your help in this matter.


Try:

....
If Len("" & Me!Edition_Number) > 0 Then
DoCmd.Save
End If
....

Acki
 
Reply With Quote
 
Bas Cost Budde
Guest
Posts: n/a
 
      2nd Jul 2005
if not isnull(edition_number) then
runcommand accmdsaverecord ' which I prefer over docmd.save
docmd.close acform, me.name
end if

StevenIpek. wrote:

> I have written the following, but if the "Edition_Number" field is empty, it
> will store an empty record, how can I make it look at that field to see if
> there is any text or not?

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html
For human replies, replace the queue with a tea

 
Reply With Quote
 
Pat Hartman
Guest
Posts: n/a
 
      3rd Jul 2005
For starters DoCmd.Save saves the form NOT the record. The record is
"quietly" being saved by Access in the background when the form closes. You
need to change this to:
DoCmd.RunCommand acCmdSaveRecord

Any edit code of this nature MUST be placed in the FORM's BeforeUpdate
event. No other event will be satisfactory. If you attempt to put it
anywhere else, you will need to place it in multiple events in order to trap
all the situations in which Access quietly (without notifying you) saves a
record. In the BeforeUpdate event, you can cancel the update if the
required field is empty:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.Edition_Number = "" or IsNull(Me.Edition_Number) Then
Cancel = True
MsgBox "blah, blah, blah", vbOKOnly
Me.Edition_Number.SetFocus
End If
End Sub
"StevenIpek." <(E-Mail Removed)> wrote in message
newsFC7EAF2-C3E0-4948-8F4A-(E-Mail Removed)...
> I have written the following, but if the "Edition_Number" field is empty,

it
> will store an empty record, how can I make it look at that field to see if
> there is any text or not?
> Private Sub Close_Edition_Number_Form_Click()
> On Error GoTo Err_Close_Edition_Number_Form_Click
>
> DoCmd.Save
> DoCmd.Close
>
> Exit_Close_Edition_Number_Form_Click:
> Exit Sub
>
> Err_Close_Edition_Number_Form_Click:
> MsgBox Err.Description
> Resume Exit_Close_Edition_Number_Form_Click
>
> End Sub
> Thank you in anticipation for your help in this matter.



 
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
Default Text field to Lookup field =?Utf-8?B?RGF2aWRLZXJuQWJyYWhhbQ==?= Microsoft Access Database Table Design 3 20th Jun 2007 12:14 AM
Can I make a lookup field look in a query from another mdf? =?Utf-8?B?QWNjZXNzQW1hdHVlcg==?= Microsoft Access 2 28th Apr 2006 04:36 AM
Creating empty date field with make-table query TT Microsoft Access Queries 3 24th May 2004 09:03 AM
Make a field lookup dependent on the value in another field of a record? James H. Power Microsoft Access Database Table Design 11 22nd May 2004 09:10 PM
How to make an query and select on wether a memo field is empty or not =?Utf-8?B?UGV0ZXI=?= Microsoft Access Queries 1 2nd Feb 2004 07:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:53 PM.