Hi,
I'm new so try to bare with me. I'm using access 2000 and I created a database where the user is prompted to click on a command button and the info that was put on the form is sent to a table. This is what I have so far: -
Private Sub cmdadd_Click()
-
Dim db As Database
-
Dim rst As Recordset
-
Dim strCriteria As String
-
Dim intPointer As Integer
-
-
Set dbspushdb = OpenDatabase("push.mdb")
-
Set rst = dbspushdb.OpenRecordset("Projects", dbOpenDynaset)
-
-
' Ensure that key fields are not empty.
-
-
If kittyID = "" Or kittyID = " " Then
-
MsgBox prompt:="Please Input Kittyhawk Task Number!", _
-
buttons:=vbOKOnly + vbExclamation, _
-
title:="Vailidation Error"
-
kittyID.SetFocus
-
Exit Sub
-
End If
-
-
With rst
-
-
' If key field has been updated, add NEW record else ...
-
If .Locked = False Then
-
.AddNew
-
Else
-
' ... find existing record.
-
strCriteria = "[kittyID] = " & Projects & ""
-
.FindNext strCriteria
-
.Edit
-
End If
-
-
' Update table with form details
-
.Edit
-
.Fields("kittyID") = kittyID
-
.Fields("cboStore") = cboStore
-
.Fields("cboManager") = cboManager
-
.Fields("ProjectTitle") = ProjectTitle
-
.Fields("Jdial") = JdialNumber
-
.Field("ProjectDescription") = ProjectDescription
-
.Fields("StartDate") = StartDate
-
.Fields("EndDate") = EndDate
-
.Fields("ProjectOffice") = ProjectOffice
-
.Update
-
End With
-
-
With Projects
-
' Refresh List.
-
.Requery
-
' Ensure that the record selected in list matches current
-
For intPointer = 0 To .ListCount - 1
-
If .Column(0, intPointer) = rst.Fields("Projects") Then
-
.Selected(intPointer) = True
-
Exit For
-
End If
-
Next intPointer
-
.SetFocus
-
End With
-
-
rst.Close
-
-
Projects.Locked = True
-
Please help.
9 5000
If the form's record source is the table and it's open as a dynaset, then you don't have to tell it to update the table with the information. It'll do that automatically as you enter information.
-
' Update table with form details
- .Edit ' this overrides the .AddNew statement - remove it
-
.Fields("kittyID") = Me.kittyID
-
.Fields("cboStore") = Me.cboStore
-
.Fields("cboManager") = Me.cboManager
-
.Fields("ProjectTitle") = Me.ProjectTitle
-
.Fields("Jdial") = Me.JdialNumber
-
.Field("ProjectDescription") = Me.ProjectDescription
-
.Fields("StartDate") = Me.StartDate
-
.Fields("EndDate") = Me.EndDate
-
.Fields("ProjectOffice") = Me.ProjectOffice
-
.Update
-
End With
-
The Me. designates fields on the form. Make sure the control names are correct. -
With Me.Projects ' assume this is a listbox control name
-
' Refresh List.
-
.Requery
-
' Ensure that the record selected in list matches current
-
For intPointer = 0 To .ListCount - 1
- ' if column0 is the bound column then
-
If .ItemData(intPointer) = rst.Fields("Projects") Then
-
.Selected(intPointer) = True
-
Exit For
-
End If
-
Next intPointer
-
.SetFocus
-
End With
-
-
rst.Close
-
Set rst = Nothing
-
Set dbspushdb = Nothing
-
-
Projects.Locked = True
-
NeoPa 32,556
Expert Mod 16PB
If the form's record source is the table and it's open as a dynaset, then you don't have to tell it to update the table with the information. It'll do that automatically as you enter information.
As Rabbit says, while it's possible to do all sorts of complicated stuff in VBA in Access, you really would be better advised (unless you know a reason why not, that you've not shared with us) to create a form bound to the underlying recordset (table) and letting Access handle the updates automatically.
Otherwise a simple append query that grabs the info directly from the control will do.
NeoPa 32,556
Expert Mod 16PB
As in post #4, it's possible, but why complicate your life doing it the complicated way when Access provides a natural way of doing it :confused:
As in post #4, it's possible, but why complicate your life doing it the complicated way when Access provides a natural way of doing it :confused:
I have tried it that way but nothing happen. I have a submit button on the form once it is click it does nothing to enter records into the table. I even used the command button wizard but still no luck. I have ask the same question in a different form and some users gave me hints about diming a database and things of that sort which I knew nothing about. So I came here and from that this forum has been very helpful to me with recent questions and quick responses. This is what I have now: - Dim db As Database
-
Dim rst As Recordset
-
Dim strCriteria As String
-
Dim intPointer As Integer
-
-
Set dbspushdb = OpenDatabase("push.mdb")
-
Set rst = dbspushdb.OpenRecordset("Projects", dbOpenDynaset)
-
With rst
-
-
If .Locked = False Then
-
.AddNew
-
Else
-
End If
-
' Update table with form details
-
.Fields("kittyID") = kittyID
-
.Fields("cboStore") = cboStore
-
.Fields("cboManager") = cboManager
-
.Fields("ProjectTitle") = ProjectTitle
-
.Fields("Jdial") = JdialNumber
-
.Field("ProjectDescription") = ProjectDescription
-
.Fields("StartDate") = StartDate
-
.Fields("EndDate") = EndDate
-
.Fields("ProjectOffice") = ProjectOffice
-
.Update
-
End With
-
-
rst.Close
-
Set rst = Nothing
-
Set dbspushdb = Nothing
-
-
Projects.Locked = True
Where do I go from here?
NeoPa 32,556
Expert Mod 16PB
I would suggest trying it the normal way.
Get the Forms wizard to help you create a form bound to your table or query.
Almost all of the extra stuff is then unnecessary.
When you look at what it creates for you, then you will understand better what I'm talking about.
I would suggest trying it the normal way.
Get the Forms wizard to help you create a form bound to your table or query.
Almost all of the extra stuff is then unnecessary.
When you look at what it creates for you, then you will understand better what I'm talking about.
I've tried the wizard command button again. It gives the error that "It can't go to specified record". So what I done to hopefully try to fix the problem was I compact and repair database. Do you think this will help me?
NeoPa 32,556
Expert Mod 16PB
I don't know if you're replying to my post or whether you just clicked on the Reply button to post.
If you haven't read my last post I suggest you do so, or at least let me know that you're not interested in my continued contributions.
If you are actually replying to my post, then I suggest you check it again, as it says to try the Form wizard NOT the command button control wizard.
Please let me know how you get on (or alternatively let us know if you need help to do this).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Martin |
last post by:
There is an Access table on the network. 15 users who do not have Access are
connected to the network. Is there a way for each user to be able to enter one
or more rows containing 3 or 4 columns to...
|
by: Hasanain F. Esmail |
last post by:
Hi,
Your help will be greatly appriciated.
I have a table with following fields. Table's name is tblTicketNumers
TicketNumberID (It is a key field)
TicketNumber (Text field)
AgentsName (Text...
|
by: Andrew Arace |
last post by:
I scoured the groups for some hands on code to perform the menial task
of exporting table data from an Access 2000 database to Oracle
database (in this case, it was oracle 8i but i'm assuming this...
|
by: moondaddy |
last post by:
I have a user control being used instead of a frame page. when the user
clicks on a menu item I need to send the ID (integer value) of that menu as
a parameter in the postback of the user control...
|
by: JIM.H. |
last post by:
Hello,
Can I send a dataset as a parameter into stored procedure and import data to
a table in the stored procedure?
Thanks,
Jim.
|
by: mcraven.2 |
last post by:
How do you send a browser to a link when a command is given? I've
tried using Java Server Pages <jsp:forward /command but that doesn't
change the link in the address bar and some other problems...
|
by: southoz |
last post by:
Good ay all ,
I'm fairly new to access(a little over 5 weeks now). Since I'v started I have picked up a lot of useful information from forums such as this and in doing so will share that information...
|
by: bmallett |
last post by:
First off, i would like to thank everyone for any and all help with this. That being said, I am having a problem retrieving/posting my dynamic form data. I have a form that has multiple options...
|
by: Dave |
last post by:
Hello All,
These one may be a bit tricky, and what I'd like to do may not even be
possible. I would love to hear any ideas you guys have for solving
this.
Here is the situation: I have a form...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |