How to make cmd buttons (undo & clear) work on subforms

On the Main form I have cmd buttons that clear and undo.

Specifically the Undo doesn't undo the subforms, just the Main form. I also am not sure how to make my clear button, clear out all controls on all 3 forms.

Sponsored Links:

Related Topics

Delete Record
When I run this code, it works fine, but I get a value of "#Deleted" in the controls. What am I doing wrong?

If MsgBox("Are you sure you would like to delete History" & _ " from this record only", vbQuestion + vbYesNo,= vbYes Then
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "DELETE FROM tblPre WHERE Number = '" & Me.[Ratio Number] & "'"
Me.Refresh Else End If

Buttons doesn't work in Subforms
I'm kinda newbie in access. I got sort of a dumb question ('cause I know I'm doing something wrong I just don't know what. I looked for answers but couldn't find any.)

it goes like this :
I have 2 reports and one form for example
on the 2 reports I have a command buttons that opens another form that contains the record values

when I view the report separately the button work.
when I put it in the main form as a sub forms the buttons suddenly pops up a parameter missing alert box ( I mean the one you can fill the value and hit ok)

the event of the buttons is onClick macro
open form
where [reports]![name of report][name of field]=so on.

hope I'm clear on my questions and that for you guys it's a kinder garden question!

sorry about the english . it's not my native!
hope to hear good news

Enable Button based on Date box Values
I am getting confused trying to code a button after dates have been entered in two boxes - Start Date and End Date

On opening the form the cmd button (View Reports) is disabled. The user enters dates in the Start and End date boxes, once this is done the cmd button enables.

However if they decide to clear the dates (using another cmd button 'clear Dates') then I need the View Reports button to go back to being disabled.

I have tried the following on lost focus, on change ect but noting seems to work!

'Enables Cmd View Report if dates have been entered
If Me.txtDateStart.Value = "" And Me.txtDateEnd.Value = "" Then
Me.cmdViewReport.Enabled = False
Me.cmdViewReport.Enabled = True

Link Tables with A Master table & Two Other unconnected tables
Title to this question probably not very clear, I should know this but for some reason I can't work it out. It is either obvious or not possible at all in a simple query.

I have a table "Master" & tables "A" & "B"
A & B are actually the main tables with thousands of records.

Master is a selection of either A or B on Todays Date, 20 or so records.

Master has a Link ID to A
Master has a Link ID to B

A & B are not related

Is there a way to set up a single query that shows all the records
where Master has a matching A & Master has a matching B

If I link Master to both tables ID of course there is no match throughout all the tables.

Don't want them on seperate subforms

I don't think I have made that very clear but hopefully get the gist

Setting the Focus to a Navigation Sub Form
seems ages since I was last on here but am back to finishing off my DB and need some advice again !

I have a Access Navigation form, with subforms within each 'button' one of these buttons is called 'Treatment Menu' (NavigationButton19)

On the 'Treatment Menu' subform (called 'NavigationSubform' by default) I have some cmd buttons to open the relevant user forms. when any of the buttons are clicked the relevent user form opens and the Navigation form closes.

On the current open user form I have put in a cmd button called 'Return' - which is where the problem is.

Is there a way I can return to the Navigation form to the same point that I came from - in this case the 'Treatment Menu' subform?

I have tried using Docmd and Forms! ect ect but nothing seems to be working

Access 2007 Saving File
Wondering if anyone has same problem as I do and if there is a fix or trick? Access 2007 Esc and Undo together are nice to recover accidentally deleted data. My problem is that while I'm typing and accidentally delete data somehow that the Esc and Undo work against me by recovering back to some previous point in my work and not allowing me to recover what Access thinks ishelping.

To me Microsoft has it backwards. I have to Save the File, then make a change, then undo it, then save it again. before the Esc and Undo cannot lose my work for me. They should haveREVERSED this process and made recovery take 4-5 steps not saving (which I do when entering technical & difficult data about every 60 seconds.
The other problem is every time I save data (large text fields) the cursor goes to the top of the field and I find only Top or Bottom choices available. The amount of time I spend saving(for sure) and getting back to where I was takes nearly as long as the data I enter between each save : ( is anyone else having this problem?

So what I'm asking is a way to save the Access file without Esc or Undo messing it up, and how to get the cursor back where it was at the time of the save. I'm guessing a macro may do itbut I'm not familiar with the vb code stuff people talk about.

I understand that 'DoCmd.GoToRecord , , acNewRec' works fine in
clearing the records in a form and presenting a fresh form for data entry for the user. I have a form which contains a few subforms. After data is
entered I need to clear the fields for new data entry, so I tried the
above code and it dosent seem to work. Is it because I am trying to clear
the records of the subform from the main form? Is there a way around
this? I really need to have the form holding all the subforms.

VBA Script to run select query
Dim cmd As ADODB.Command
Dim strQueryText As String

cmd.ActiveConnection = CurrentProject.Connection

cmd.CommandType = adCmdText
strQueryText = "SELECT Store_Profile.SPStoreNo, Store_Profile.SPSiteNo, Contact_Profile.CPExtAcctPhoneNo, Contact_Profile.CPExtAcctFaxNo"
strQueryText = strQueryText & "FROM Contact_Profile INNER JOIN Store_Profile ON Contact_Profile.SPStoreNo=Store_Profile.SPStoreNo" & ";"
cmd.CommandText = strQueryText


ADODB RecordCount
Can someone please tell me how to get an accurate RecordCount from an ADODB RecordSet?

I've tried using adOpenStatic CursorType and adLockOptimistic LockType. I've also tried moving from the first to the last record; all of these are suggestions from the web but they do not work.

I currently have this:

Sub b()
Dim conn As ADODB.Connection
Dim cmd As ADODB.Command
Dim rst As ADODB.Recordset
Set conn = New ADODB.Connection
conn.Open CurrentProject.Connection
Set cmd = New ADODB.Command
cmd.ActiveConnection = conn
cmd.CommandText = "SELECT DocumentNumber, Revision, FROM PartImport WHERE ([DocumentNumber] = '" & strPartNumber & "');"
Set rst = cmd.Execute
Debug.Print "Recordset recordcount: " & rst.RecordCount
Set rst = Nothing
Set conn = Nothing

'Find' code
New to this site, and hope I may be able to source some help. Im a bit rusty on my code knowlege:
I have a form with a cmd button with the following code behind it:

Private Sub Find_Click()
Me.RecordsetClone.FindFirst "[RecordNo] = " & Me![FindNo]

If .NoMatch Then
MsgBox "Audit Code Incorrect"
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
End Sub

I get a compile error saying 'invalid or unqualified reference.
Basically, the intension is for an operator to input a number into txt box 'FindNo' and then press cmd 'find'. Then the appropriate record from the 'record source' table is displayed. Other txt boxes on my form have their control set to other fields in the table. Without the If statement, the code works, but hopfully the reason for wanting an if statement will be clear, but I cant make it work

Using module to modify form
I've managed to create a form that accepts usernames and passwords and once a user enters a correct username/password the form closes and opens the mainpage of the database (simply has many cmd buttons to allow users to open reports, view/update data etc.). Each user has a different level of access (there are a total of 3 levels of access). Instead of creating a form for each level of access that has the appropriate buttons I'm hoping to use one form and simply use some form of VBA to enable/disable the buttons. I'm thinking this would be best done in a module, however, I'm not sure of how to set text box/cmd button properties from inside a module. if this is even possiable.

Should I attempt to use only one form w/ VBA to enable/disable all the buttons depending on access level or just stick w/ my current plan and make 3 seperate forms, one for each level

Why does my Undo button become active for some changes but not others.
I have an Undo button on my form that is supposed to become active whenever a change is made. This works fine whenever I change a bound field.

However, I also have unbound fields on the form. Once I change an unbound field, this appears to mess up the UnDo logic as from that point, changing a bound field no longer causes the Undo button to become active.

Ideally, I'd like the UnDo button to work with both bound and unbound fields but at least I'd like to prevent the unbound fields from messing up the UnDo for the bound fields.

Conditional Formatting through VBA: On Undo
I've moved all my conditional formatting to VBA because of performance issues with Access's built-in conditional formatting facility, but there's one feature I can't replicate. Some of my formatting involves highlighting fields if they're blank. This works fine for On Current and After Update, but I can't get it to work for On Undo: if I undo changes and thereby leave a field blank, I can't get the conditional formatting to kick in again. Am I missing something about On Undo, or is there another way of doing this?

Conditional Formatting through VBA: On Undo
I've moved all my conditional formatting to VBA because of performance issues with Access's built-in conditional formatting facility, but there's one feature I can't replicate. Some of my formatting involves highlighting fields if they're blank.

This works fine for On Current and After Update, but I can't get it to work for On Undo: if I undo changes and thereby leave a field blank, I can't get the conditional formatting to kick in again.

Am I missing something about On Undo, or is there another way of doing this?

Assign a command to a variable and then run the variable?
I have a form that has two textboxes, txtStartDate & txtEndDate, that are used as criteria for a query. Also on the form are two buttons, btnRefresh & btnPrintReport. Both buttons need do to the same checking to make sure that the textboxes have dates in them.

I would like to make that check be done in a function. The problem is that what needs done in the If False portion is different for the two buttons.

btnRefresh will requery a subform and btnPrintReport will open a report.

Open report using Me.Filter?
I've created a form with a datasheet subform showing teacher contact data.

On the main form - I have multiple cmd Buttons that each have different filters (filters by course). They work great. Now how do I get filtered data to my report?

Created new cmd button -- with one click: DoCmd.OpenReport "TeachersByCourseRpt", acViewPreview, , Me.Filter
my filter buttons:

With Me.TeachersbyCourseFrm.Form

.Filter = "[Explor Tech] = -1"

.FilterOn = True

End With

Shouldn't this work?!? It doesn't. I click a button, the filter applies perfectly, I click my preview report button -- but it shows all records not just the filtered ones on the report. Oh, I should mention that the subform is based on a query. Report is based on that same query

Undo changes
Learn: Undo changes in Design view, Undo changes when adding or editing records in a datasheet or form, Undo changes when adding or editing records in a data access page, Revert to a saved version of a form or report.

Command Buttons in a Form
I am new to Access & trying to create a form/database, but the command buttons I added don't seem to work. I have ensured that Data Entry is checked off in properties, but suspect that there needs to be some sort of relationship established between the command buttons & the form/database.

Delete Record with related Table & Sub form.
I am trying to delete a record but it gives me runtime error 3200 saying have related Subform & Tables.

I require a code to delete a record through a cmd button deleting only the current record with the related record in subform & tables.

I think code needs to be put up in onClick Event

Also would like to know how to clear all the data to start entering a fresh data.

Deselect all checkboxes in Access 2007 form
I have created a split-form (Form_ChkBx)to display records in my table (MST_Table). The bottom portion of the split-form has datasheet view, the top portion has two control buttons, "Clear" & "Exit".

I would like to program the "Clear" button to loop through the form or table and deselect (clear or reset) all checkboxes.