A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Requiring Data in field on Form with enter new record in Subform



 
 
Thread Tools Display Modes
  #11  
Old March 2nd, 2006, 08:18 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Requiring Data in field on Form with enter new record in Subform

I'm not sure what form you are referring to - I thought we were talking
about a subform. Post your code and I'll take a look.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


mma40 wrote:
Finally, I figured out what I was doing. My county field is called
Combo251 because I added it later and forgot. But I now have another
problem. Once i click ok to "county must be entered", it goes ahead
and opens the other form. How do I keep that from happening before
the fields are done?



  #12  
Old March 2nd, 2006, 09:26 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Requiring Data in field on Form with enter new record in Subform

Here is my code. I have it check for required fields of an existing
record when a command button on the Main form is clicked. Once all
required fields are entered, my dataentry form opens to input
information that goes back to a linked table. Even though I have the
focus on the Main form, it goes ahead and opens the dataentry form.

Private Sub VisitEntry_Click()
On Error GoTo Err_VisitEntry_Click

'Only check existing records
If Not Me.NewRecord Then
If IsNull(Me.County) Then
MsgBox "County must be entered"
Me.County.SetFocus
ElseIf IsNull(Me.EthnicGroup) Then
MsgBox "Ethnic Group must be entered"
Me.EthnicGroup.SetFocus
End If
End If

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "VisitEntry"

stLinkCriteria = "[UserNumber]=" & Me![UserNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_VisitEntry_Click:
Exit Sub

Err_VisitEntry_Click:
MsgBox Err.Description
Resume Exit_VisitEntry_Click

End Sub


Sorry to be a pain. I am new to this and trying to find info on the
questions already posted but that is not very easy. Thank you for your
time and expertise.

  #13  
Old March 2nd, 2006, 09:33 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Requiring Data in field on Form with enter new record in Subform

Here is my code. I have it check for required fields of an existing
record when a command button on the Main form is clicked. Once all
required fields are entered, my dataentry form opens to input
information that goes back to a linked table. Even though I have the
focus on the Main form, it goes ahead and opens the dataentry form.

Private Sub VisitEntry_Click()
On Error GoTo Err_VisitEntry_Click

'Only check existing records
If Not Me.NewRecord Then
If IsNull(Me.County) Then
MsgBox "County must be entered"
Me.County.SetFocus
ElseIf IsNull(Me.EthnicGroup) Then
MsgBox "Ethnic Group must be entered"
Me.EthnicGroup.SetFocus
End If
End If

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "VisitEntry"

stLinkCriteria = "[UserNumber]=" & Me![UserNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_VisitEntry_Click:
Exit Sub

Err_VisitEntry_Click:
MsgBox Err.Description
Resume Exit_VisitEntry_Click

End Sub


Sorry to be a pain. I am new to this and trying to find info on the
questions already posted but that is not very easy. Thank you for your
time and expertise.

  #14  
Old March 2nd, 2006, 09:40 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Requiring Data in field on Form with enter new record in Subform

Just add logic so that the form is not opened. Using a boolean variable you
can control whether the openform occurs. Also you should probably move the
Dim statements to the top of your procedure. While it's not technically
wrong for them to be inline, it's also unusual and could make it hard to
debug.

Private Sub VisitEntry_Click()
Dim stDocName As String
Dim stLinkCriteria As String
'New variable
dim fContinue as Boolean

On Error GoTo Err_VisitEntry_Click
'Start with fContinue true then mark it
'false whenever a field needs to be fixed
fContinue = true
'Only check existing records
If Not Me.NewRecord Then
If IsNull(Me.County) Then
MsgBox "County must be entered"
Me.County.SetFocus
fcontinue=false
ElseIf IsNull(Me.EthnicGroup) Then
MsgBox "Ethnic Group must be entered"
Me.EthnicGroup.SetFocus
fcontinue=false
End If
End If

if fContinue then
stDocName = "VisitEntry"
stLinkCriteria = "[UserNumber]=" & Me![UserNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria
endif

Exit_VisitEntry_Click:
Exit Sub

Err_VisitEntry_Click:
MsgBox Err.Description
Resume Exit_VisitEntry_Click

End Sub


--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.


mma40 wrote:
Here is my code. I have it check for required fields of an existing
record when a command button on the Main form is clicked. Once all
required fields are entered, my dataentry form opens to input
information that goes back to a linked table. Even though I have the
focus on the Main form, it goes ahead and opens the dataentry form.

Private Sub VisitEntry_Click()
On Error GoTo Err_VisitEntry_Click

'Only check existing records
If Not Me.NewRecord Then
If IsNull(Me.County) Then
MsgBox "County must be entered"
Me.County.SetFocus
ElseIf IsNull(Me.EthnicGroup) Then
MsgBox "Ethnic Group must be entered"
Me.EthnicGroup.SetFocus
End If
End If

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "VisitEntry"

stLinkCriteria = "[UserNumber]=" & Me![UserNumber]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_VisitEntry_Click:
Exit Sub

Err_VisitEntry_Click:
MsgBox Err.Description
Resume Exit_VisitEntry_Click

End Sub


Sorry to be a pain. I am new to this and trying to find info on the
questions already posted but that is not very easy. Thank you for
your time and expertise.



  #15  
Old March 2nd, 2006, 09:43 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Requiring Data in field on Form with enter new record in Subform

Also - no apologies necessary - I (and others) wouldn't answer questions if
we didn't feel like helping others. This is how many of us got started. You
might want to try using Google for finding answers to more common questions.
Look under the Groups tab of Google to see newsgroup threads that pertain to
your search key words.

--
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.



Sorry to be a pain. I am new to this and trying to find info on the
questions already posted but that is not very easy. Thank you for
your time and expertise.



  #16  
Old March 3rd, 2006, 03:34 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Requiring Data in field on Form with enter new record in Subform

Great!! That works perfectly. Thank you.

 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box NotInList - How To Add Data To Underlying Table 10SNUT Using Forms 19 July 8th, 2005 09:12 PM
Need Help In Printing Current Record in Specific Report RNUSZ@OKDPS Setting Up & Running Reports 1 May 16th, 2005 09:06 PM
Prevent Blank Records being written. Need Help. Robert Nusz @ DPS Using Forms 4 December 29th, 2004 05:15 PM
dlookup miaplacidus Using Forms 9 August 5th, 2004 09:16 PM
Recordset in subform based on field in parent form Lyn General Discussion 15 June 14th, 2004 03:10 PM


All times are GMT +1. The time now is 01:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.