Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is this possible?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,

I have a form that will automaticaly update a table(thanks to Maquis),now I have another problem.

Right now, the data from the form replaces the data in the first row. I need it to append the data to the table, or I need to have the value from the text box added to the number in the table where the activities are the same. I also have to call on a function on this number before it gets put in the table.

The form has one text box and one combo.

I'm trying to not use ADO(Don't know it) or DAO(won't work for me). Is something like this possible?

thanks

Kris
 
Hi Kris!

The user needs to go to a new record before adding anything (or changing anything on the form). As you have found out, if you are on an existing record and make changes to bound controls, those changes will affect existing data. If you want a more recognizable button to add a record, you can make your own by dragging a command button onto the form and following the wizard. In the first screen, choose record operations in the left box and add new record in the right box. On the second screen, you can type in what you want the button to say (if you put an & before one of the letters, it will become a hot key on your form).

You say in your post that you don't want to use ADO or DAO, but are you willing to see some VB solutions to the same problem?

hth
Jeff Bridgham
 
Hello,

Thanks for the reply. I'd love to see some VB solutions.

I would like to use DAO as that is my prefence, but for some reason when I try to do the following:
set db = ws.OpenDatabase("E:\Database\Database\Volunteer\Volunteer.mdb") it complains that it can't find the database. The path is correct, and E is the letter of the mapped drive I'm using.

So I needed to come up with other solutions.

Thanks again for advice it helped alot.

Kris
 
Hi again!

My favorite way of handling additions and editing with the same form is to create a menu form which will have a number of buttons on it which will allow the user to follow different paths through the database depending on what they want to accomplish. The first thing you'll want to do is set your form's AllowAdditions property to false. On your menu form you will need a button to add information and another to edit information. In these buttons' Click events use the following code:

Add Button:
DoCmd.OpenForm "YourFormName",,,, acFormAdd,, "Add"

Edit Button:
DoCmd.OpenForm "YourFormName"

On your add/edit form you will want a button to allow the user to add a second record if they need to (I usually have the caption on the button read Add Another?). You will want to set the buttons visible property to no. In the Form_Load event use the following code:

If Me.OpenArgs = "Add" Then
YourButtonName.Visible = True
End If

Finally, in the form's BeforeUpdate event you will want to put code to test the viability of the data. The following code just tests for existance of data in the text box:

Private Sub Form_BeforeUpdate(Cancel as Integer)

If IsNull(textbox.value) Or textbox.value = "" Then
If MsgBox("You put no data in the text box. If you continue no data will be " & _
"saved. Do you want to continue?", vbYesNo)=vbYes Then
Me.Undo
DoCmd.Close acForm, Me.Name
Else
Cancel = -1

End Sub

You can of course put much more in the validation routine.

hth
Jeff Bridgham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top