Topics Search

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

How to make cmd buttons (undo & clear) work on subforms
Views: 60
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:

More 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