My DoCmd.SearchForRecord command stopped working - ms-access-2007

I have a dropdownlist that has 4 columns but only 3 are 'visible' the first one is an ID, and after update I have the following code run.
DoCmd.SearchForRecord acDataForm, "new_order_thingy", acFirst, "[OrderID] = " & Me.Combo112.Column(0)
This used to get the record pertaining to the OrderID, I am not sure what I did but I somehow broke it. I don't get an error but it doesn't retrieve any data.
It does pass the correct value in Me.Combo112.Column(0) when I MsgBox it out.
Any help/suggestions would be appreciated.
Thanks

I suggest you place a breakpoint in your code. Then, change the value in the combo, and in break mode, hover the mouse over the variables.
This will also show you if the event is really fired.
Sometimes the link between the event and the procedure is lost (e.g. when you rename the object).

The Form.DataEntry was set to YES, it should have been set to NO ... don't get why but thats what was causing my error.

Related

Cannot disable UltraGrid cells

I have an UltraGrid in my project. Data can be entered into each cell, which is then saved to the database. I want to be able to disable all of the cells in the current row EXCEPT for one called Product_Code. Once data has been entered into the active row column (this is entered via a ValueList), I then want all of the other cells to become available for entering data into.
So far I have tried
If Me.ugProducts.ActiveRow.Cells("Product_Code").Value.ToString = "" Then
Me.ugProducts.ActiveRow.Cells("Product_Volume").Activation = Activation.Disabled
Else
Me.ugProducts.ActiveRow.Cells("Product_Volume").Activation = Activation.AllowEdit
End If
But to no success. When the project is built, all of the cells are immediately available to type into, despite no value having been entered.
Why is it not working? What is the best way to do this?
I saw a previous comment on here that has since been deleted, for some reason... However, one solve you can try is:
In the form load; add in ugProducts.DisplayLayout.Override.CellClickAction = CellClickAction.CellSelect - This will mean all of the cells are disabled, but you'll still be able to select the ValueList for Product_Code
Now, in the CellListSelect event of ugProducts, use the following code ugProducts.DisplayLayout.Override.CellClickAction = CellClickAction.Edit (After any validation checks or anything that you have in the method already, it will go in here somewhere, just keep trying things if you aren't too sure where)
Anyway, this should now let you fill them in as you wish.

Unbound DataGridView add row with checkbox error

This is a Windows forms program. I have an unbound DataGridView control with four columns; Feature ID as string, Parts as string, Flats as string and ShowOnEst as boolean. The columns were defined in the form designer and the boolean column is, indeed, set to be a checkbox with tristate set to false.
The user selects a product from a list box and this code is executed to populate the grid
grdFeat.Rows.Clear()
For i = 0 To curProduct.lstFeatures.Count - 1
With (curProduct.lstFeatures(i))
grdFeat.Rows.Add(.FeatureId, .Parts, .Flats, .ShowOnEst)
End With
Next
If AllowUserToAddRows is false, everthing is good. Setting AllowUserToAddRows to true, however, results in the following error:
FormatException
Value '' cannot be converted to type 'Boolean'.
The error is NOT triggered in my code. It's displayed in a new tab titled "No Source Available".
It seems pretty clear that the process that adds the new editing row is trying to set the checkbox to a string value, or perhaps NULL. I'm very new (a few months) to vb.net, so I suspect I'm overlooking some simple setting somewhere, but after several hours of trying to find it, I'm starting to feel a little foolish here.
I'd give you a list of things I've tried already, but it's a long one. :) I even tried to go around the issue by adding a new row manually, .add("","","",False), but that too gives the same error, even though I'm telling it what to put in the checkbox.
What am I missing? Also, can someone point me to an explanation of how that new editing row thingy works?
From what you explained, I have no real explanation for the problem.
A workaround may be to set AllowUserToAddRows to false before populating the DataGridView and set it to true after.
Found it. Hope it helps someone else...
The rows being added are uncommitted rows. To solve it, capture the row added index, set the current cell and notify that the added row is dirty:
grdFeat.Rows.Clear()
For i = 0 To curProduct.lstFeatures.Count - 1
With (curProduct.lstFeatures(i))
Dim p = grdFeat.Rows.Add(.FeatureId, .Parts, .Flats, .ShowOnEst)
End With
grdFeat.CurrentCell = grdFeat.Rows(p).Cells(0)
grdFeat.NotifyCurrentCellDirty(True)
Next
Well, with further experimentation, this isn't a total fix. The problem is still there, but at least now handling the DataError event allows me to do something with it in code. Without these lines, the error occurs before the DataError event is triggered.
Still puzzled.

Copy Value from combo list on login screen to username field on new form

Newer to access...I am trying to copy the value selected from the combobox on the log in screen to a field on the new form that opens after successful login.
The field I need copied is called cmoemployee on the Login form.I need that to go to the username field on the mainframe form.
Any help would be greatly appreciated! I have tried many different ways but I can't seem to get it.
Haha,
I actually know what you mean here. This can be a complete pain as the variables are deleted when you open a new form In general it is better to show what you have tried so people are able to help you fix it. Anyway, I've tried to do this so I know how frustrating it can be. There are two main ways that this can be done. You can open the form with openargs (I do not think this is a good option for you as you will have to have the openargs constantly transferring from one form to the next and will be cleared if one form misses them.
A better option would be to use tempvars which are not deleted. This is the code I used to do something similar:
I am going to assume your combobox is two columns (but only displays one) and the bound column is the primary key to an employee table. In which case this would work (or you can modify it to meet your needs)
Log in:
'Check Password (or however you check it
If StrComp(txt_Password, DLookup("[Password]", "tbl_Employee", "[ID] = " & cmoemployee), 0) = 0 Then
TempVars.Add "MyEmpID", cmoemployee.Value 'TempVars will store the combobox value
Else
Msgbox "Incorrect Password Please try again"
End If
On Load event of mainfraim form:
[UserName] = TempVars!MyEmpID
That should get you started, so you can build the rest. Let me know if you have any questions.

How to assign the value of textbox in first form into a checkbox on another form

Of course this must be simple. I have done this a thousand times but today I cant see the wood for the trees somehow. I want to do this... Me!ProjectID = Forms!Another.ProjectID
But I have the Another field reporting in the watch window correctly as value 50, and after assignment Me!ProjectID = 1....Dur!
I have tried it using periods instead of exclamation marks and using the .value property but nothing is altering the value post assignment to what it should be.
Its in the Form_open procedure. the checkbox, it has a lookup and ProjectID is the bound column.
Any thoughts appreciated.
Yep Braindead day - the answer is simple an OnCurrent event was also firing and resetting the ProjectID value!

How do you increment a variable by +1 on a button click?

Hello kind helpful people,
I am having a major problem in Qlikview. I am just trying to create a button that can increment a variable by +1 each time it is clicked. I thought i could simply write an expression on a button click event but Qlikview is so different. I think it overcomplicates this matter by trying to be too simple.
The only thing i can do is 'Set a variable' to a specific value in the button properties.
Does anyone know how to do this?
Many thanks
Eddy
You can do this like you originally tried with an expression in the button action... the key is to make sure you put the = in there so vCount (or whatever your variable is called) gets evaluated first.
I am unable to add a comment, but I wanted to make sure you knew that macros won't work on server, so if you are doing it just for you it should be fine, but if you have it run on a server it could cause problems.
No that's the thing, as i mentioned in my original post all SET VARIABLE does is set a variable to a specific value that you have to specify but you cannot (as far as I know) set an expression that will increment the variable continiously by +1.
Anyway, I figured it out - and for anyone else whose stuck on the same issue:
I found a long winded way of doing it, although it works well.
1) Create your variable in Qlikview, mine is called 'vIncrement'
2) Set up a macro by going into button 'properties' > 'Add' > action type = 'External' > 'Run Macro'
3) Then name your macro and click on 'Edit Module'
4) Paste the following bit of vbScript:
Sub Increment
TheVal = ActiveDocument.Variables("vIncrement").getcontent.string
TheVal = TheVal + 1
ActiveDocument.Variables("vIncrement").SetContent TheVal, True
End sub
5) Click OK and close
This should do the trick.
I actually figured this out in about 20 minutes and I'm a total Qlikview amatuer whose never had any formal training in it lol, but StackOverflow.com won't let me paste my own answer for atleast 10 hours because I'm new here - I cannot understand why?
Never knew about vbscripting Qlikview Macro's until 10 minutes before - not bad eh for an amatuer?
I have to admit there must be a simpler method than this...but atleast this method works.
Cheers
Eddy Jawed