473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

2 Questions on Forms - Default Value 0 giving Nulls in some fields; Editing or Adding record

Hi -
I have 2 new questions in a new database I'm trying to develop.

The first has 6 fields on a table and allows the user to enter them on
a form. The form is bound to the table.

All 6 fields are default value = 0 on the table and on the form.
Fields are filled in at different times and maybe by different people,
so I wanted them all to "initialize" to 0.

3 of the fields occasionally put Null in the field on the table, so
the report that adds them up shows a blank. I know I can nz the
fields on the report, but I am thinking that since I have default 0 on
the table and the form that might not be necessary and maybe I'm
masking another problem? This is annoying both myself and the user.

The second question is for the same form. An initial form opens where
the user selects an employee, Department and Fiscal Year. I want to
open the second form (the one where the user can enter the 6 fields)
when the user presses the "Go" button. My question is: I want to open
the form to edit a record if it exists, and add a new record if there
isn't one.

Do you do this in code - Dcount and if it's 0, open the form in Add
mode, otherwise open it in Edit mode? Or is there an easier way
(usingA2K).

thanks to all -
sara

Apr 30 '07 #1
5 2293
Hi Sara,

Since I can't see your application, it is difficult to see what is going
wrong based on your description here. But I can advise another way -
that my be worth something:

start by building a simple barebones prototype application which does
what the main one will do except in a very limited capacity. For
example, instead of 6 fields in your table and form, start out with 1
field (or maybe 2). Then, don't even worry about the report until you
get the form part fixed. Now you have a simple form that only displays
data from a table - so there is nothing hidden underneath to cause any
problems. And I understand you want to open another form based on some
criteria. The 2nd form is annoying you because it isn't doing what you
want (per what you describer below).

So your prototype will have one form that is based on one table with one
field. When you open the form, it will display the data from that
table. Then you want to open another form (we'll use a command button).

Private Sub Command1_Click()
DoCmd.OpenForm "SecondForm", acNormal
End Sub

Do you need to pass arguments to the 2nd form?

Private Sub Command1_Click()
DoCmd.OpenForm "FormName", , , , , , "Hello|GoodBy|Mary|Lamb"
End Sub

Now you can use the OpenArgs property of the 2nd form

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Dim strA As String
Dim strB As String
Dim strC As String
Dim strD As String

strA = ParseText(OpenArgs, 0)
strB = ParseText(OpenArgs, 1)
strC = ParseText(OpenArgs, 2)
strD = ParseText(OpenArgs, 3)

' Then do what you want with the resulting strings
MsgBox "The OpenArgs are:" & vbNewLine & strA & " " & strB &
vbNewLine & strC & " " & strD

End If
Public Function ParseText(TextIn As String, x) As Variant
On Error Resume Next
Dim Var As Variant
Var = Split(TextIn, "|", -1)
ParseText = Var(x)

End Function
HTH
Rich

*** Sent via Developersdex http://www.developersdex.com ***
Apr 30 '07 #2
On Apr 30, 7:14 pm, Rich P <rpng...@aol.comwrote:
Hi Sara,

Since I can't see your application, it is difficult to see what is going
wrong based on your description here. But I can advise another way -
that my be worth something:

start by building a simple barebones prototype application which does
what the main one will do except in a very limited capacity. For
example, instead of 6 fields in your table and form, start out with 1
field (or maybe 2). Then, don't even worry about the report until you
get the form part fixed. Now you have a simple form that only displays
data from a table - so there is nothing hidden underneath to cause any
problems. And I understand you want to open another form based on some
criteria. The 2nd form is annoying you because it isn't doing what you
want (per what you describer below).

So your prototype will have one form that is based on one table with one
field. When you open the form, it will display the data from that
table. Then you want to open another form (we'll use a command button).

Private Sub Command1_Click()
DoCmd.OpenForm "SecondForm", acNormal
End Sub

Do you need to pass arguments to the 2nd form?

Private Sub Command1_Click()
DoCmd.OpenForm "FormName", , , , , , "Hello|GoodBy|Mary|Lamb"
End Sub

Now you can use the OpenArgs property of the 2nd form

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Dim strA As String
Dim strB As String
Dim strC As String
Dim strD As String

strA = ParseText(OpenArgs, 0)
strB = ParseText(OpenArgs, 1)
strC = ParseText(OpenArgs, 2)
strD = ParseText(OpenArgs, 3)

' Then do what you want with the resulting strings
MsgBox "The OpenArgs are:" & vbNewLine & strA & " " & strB &
vbNewLine & strC & " " & strD

End If

Public Function ParseText(TextIn As String, x) As Variant
On Error Resume Next
Dim Var As Variant
Var = Split(TextIn, "|", -1)
ParseText = Var(x)

End Function

HTH
Rich

*** Sent via Developersdexhttp://www.developersdex.com***
This is a lot for me to digest - need some thinking and research
time. I've never used OpenArgs (at least I don't think I have). Is
that concept well-described in Help? Anywhere else to look?

I keep forgetting that when I have a problem, I should "build" the
app, like you said. Will work on that to see if I can uncover any
issues.
Thanks - for now!
sara

May 1 '07 #3
try copying the code for the 2nd form in the 2nd Form's load event. The
place the mouse cursor over the word "OpenArgs" and press the F1 key.
Help on OpenArgs should come up. It is quite well documented in Access
Help. Note: if you are suggesting that your stage of development with
VBA is still at the early level, the effort you are pursuing here may
require a little more research on VBA usage. Access Help is your
friend. So is the internet (well, for researching this stuff anyway).

Good luck.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
May 1 '07 #4
On Apr 30, 9:24 pm, Rich P <rpng...@aol.comwrote:
try copying the code for the 2nd form in the 2nd Form's load event. The
place the mouse cursor over the word "OpenArgs" and press the F1 key.
Help on OpenArgs should come up. It is quite well documented in Access
Help. Note: if you are suggesting that your stage of development with
VBA is still at the early level, the effort you are pursuing here may
require a little more research on VBA usage. Access Help is your
friend. So is the internet (well, for researching this stuff anyway).

Good luck.

Rich

*** Sent via Developersdexhttp://www.developersdex.com***
Thanks. Will do. My VBA is still new - maybe Advanced Beginner. I
understand more than I can create from scratch - in other words, I can
copy some code (not all), research the new areas, understand what it's
doing and adapt it for my use - in most cases. I still couldn't use
it from scratch, but I do understand whatever I use.

This will take me a bit, but I'll research OpenArgs.
Thanks again -
Sara

May 1 '07 #5
On Apr 30, 9:24 pm, Rich P <rpng...@aol.comwrote:
try copying the code for the 2nd form in the 2nd Form's load event. The
place the mouse cursor over the word "OpenArgs" and press the F1 key.
Help on OpenArgs should come up. It is quite well documented in Access
Help. Note: if you are suggesting that your stage of development with
VBA is still at the early level, the effort you are pursuing here may
require a little more research on VBA usage. Access Help is your
friend. So is the internet (well, for researching this stuff anyway).

Good luck.

Rich

*** Sent via Developersdexhttp://www.developersdex.com***
So, I'm not getting something. I want to open the second form with
the existing record if there is one and blank to add a record if there
isn't one. I've been reading Help and various posts on OpenArgs and
I'm not seeing how that will happen.

Do I first have to do a Docunt to see if there is a record, then if
there is, use OpenArgs to open the second form right to that record?

And if there isn't a record open the second form in Add Mode?

I just thought Access might somehow handle that all for you- before I
go to the effort of writing the code. (I've been told before that I've
worked "too hard" to write something in code when it's actually built-
in to Access).

thanks
sara

May 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
10
by: MLH | last post by:
I have an A97 table with a Yes/No field named TowJob and a form bound to that table. The TowJob control on the form is bound to the same field. It is an option group with Yes and No bttns valued...
21
by: planetthoughtful | last post by:
Hi All, As always, my posts come with a 'Warning: Newbie lies ahead!' disclaimer... I'm wondering if it's possible, using raw_input(), to provide a 'default' value with the prompt? I would...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
14
by: shamirza | last post by:
Question Do ActiveX DLLs made in VB still need the VB runtimes on the machine? ________________________________________ Answer In a word, Yes. Visual Basic does not support what is known...
4
by: Drew | last post by:
I posted this to the asp.db group, but it doesn't look like there is much activity on there, also I noticed that there are a bunch of posts on here pertaining to database and asp. Sorry for...
4
by: helenwheelss | last post by:
Access 2003, using a bound form. I'm seeing rather annoying behaviour when editing data in a control with a default value. It only happens when the form is on a new record. A specific...
1
by: sdavis1970 | last post by:
I am working on an Access 2002 database where one of the tables has five required fields making up the key. There is a form that is linked to this table which is used for adding new records. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.